Examples
This example demonstrates the creation of a sequence named shipments_ship_id_seq:
booktown=#
CREATE SEQUENCE shipments_ship_id_seq
booktown-#
START 200 INCREMENT 1;
CREATE
Once created, you can select the next number from a sequence with the nextval() function:
booktown=#
SELECT nextval ('shipments_ship_id_seq');
nextval
---------
200
(1 row)
You can also use a sequence in an INSERT command:
booktown=#
INSERT INTO shipments VALUES
booktown-#
(nextval('shipments_ship_id_seq'), 107, '0394800753', 'now');