Get next sequence value : Sequence Value « Sequence « PostgreSQL






Get next sequence value


postgres=# -- Creation of a sequence
postgres=#
postgres=# CREATE SEQUENCE shipments_ship_id_seq START 200 INCREMENT 1;
CREATE SEQUENCE
postgres=#
postgres=# -- Select the next number from a sequence with the nextval() function:
postgres=#
postgres=# SELECT nextval ('shipments_ship_id_seq');
 nextval
---------
     200
(1 row)

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








Related examples in the same category

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