PostgreSQL Sequence Functions

Sequences, also known as sequence generators or sequence objects, are generally used to generate unique identifiers for rows in a table. This page organizes functions for manipulating PostgreSQL sequences.

  1. currval

    The PostgreSQL currval() function returns the current value of the specified sequence in the current session.
  2. lastval

    The PostgreSQL lastval() function returns the result of the most recent nextval() function.
  3. nextval

    The PostgreSQL nextval() function advances the specified sequence to its next value and returns that value.
  4. setval

    The PostgreSQL setval() function resets the current value of the specified sequence and returns the specified value.