Reference sequence value in table creation statement : Sequence Value « Sequence « PostgreSQL






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=#

           
       








Related examples in the same category

1.Get sequence next value
2.Get sequence last value and increment_by
3.Get next sequence value
4.Reference sequence value in insert statement