Sequences

Learn about using sequences in the PostgreSQL database.

What are sequences?

In PostgreSQL, sequences are used to generate unique numeric identifiers for rows in a database table. This is useful when a primary key is needed, but the specific value of the key is not essential.

The CREATE SEQUENCE statement

Sequences can be created using the CREATE SEQUENCE statement and accessed using the CURRVAL() and NEXTVAL() functions. The start value, increment amount, maximum and minimum values, and whether ...