Search Postgresql Archives

Re: Remove Modifiers on Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Doesn't the SERIAL shortcut automatically do this on the fly? How
> would I set this?
>
> ALTER TABLE table_name ALTER COLUMN id SET DEFAULT nextval('foo_seq_id');

If you have existing data, say with values 1, 2, 3, etc. and you set the column to start using a sequence nextval as default, unless the sequence has been told what value to start with, it will start at 1.

Per the documentation:

SELECT setval('users_id_seq', 42); -- Next nextval (insert) will return 43

Susan Cassidy


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux