Using sequences
Sequences are helpful when you need an auto-increment integer sequence in a table.
Let's look at the following example in which we create a sequence with the default setting:
root@localhost:26258/test> CREATE SEQUENCE customer_id_seq; CREATE SEQUENCE Time: 158ms total (execution 158ms / network 0ms) root@localhost:26258/test> SHOW CREATE customer_id_seq; table_name | create_statement ------------------+----------------------------------------------------------------------------------------------------- customer_id_seq | CREATE SEQUENCE public.customer_id_seq MINVALUE 1 MAXVALUE 9223372036854775807 INCREMENT 1 START 1 (1 row) Time: 136ms total ...