Mega Code Archive

 
Categories / PostgreSQL / Sequence
 

Reference sequence value in table creation statement

postgres=# -- Creation of a sequence postgres=# postgres=# CREATE SEQUENCE myseq START 200 INCREMENT 1; CREATE SEQUENCE postgres=# postgres=# CREATE TABLE shipments ( postgres(#         id integer NOT NULL DEFAULT nextval('myseq'), postgres(#         customer_id integer, postgres(#         isbn text, postgres(#         ship_date timestamp); CREATE TABLE postgres=# postgres=# postgres=# drop table shipments; DROP TABLE postgres=# drop sequence myseq; DROP SEQUENCE postgres=#