Get sequence next value : Sequence Value « Sequence « PostgreSQL






Get sequence next value


postgres=# CREATE SEQUENCE myseq MINVALUE 0;
CREATE SEQUENCE
postgres=# -- Incrementing a sequence
postgres=#
postgres=# SELECT nextval('myseq');
 nextval
---------
       0
(1 row)

postgres=#
postgres=# SELECT nextval('myseq');
 nextval
---------
       1
(1 row)

postgres=#
postgres=# drop sequence myseq;
DROP SEQUENCE
postgres=#
           
       








Related examples in the same category

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