52.23. pg_sequences#

The view pg_sequences provides access to useful information about each sequence in the database.

Table 52.23. pg_sequences Columns

Column Type

Description

schemanamename (references pg_namespace.nspname)

Name of schema containing sequence

sequencenamename (references pg_class.relname)

Name of sequence

sequenceownername (references pg_authid.rolname)

Name of sequence's owner

data_typeregtype (references pg_type.oid)

Data type of the sequence

start_valueint8

Start value of the sequence

min_valueint8

Minimum value of the sequence

max_valueint8

Maximum value of the sequence

increment_byint8

Increment value of the sequence

cyclebool

Whether the sequence cycles

cache_sizeint8

Cache size of the sequence

last_valueint8

The last sequence value written to disk. If caching is used, this value can be greater than the last value handed out from the sequence.


The last_value column will read as null if any of the following are true:

  • The sequence has not been read from yet.

  • The current user does not have USAGE or SELECT privilege on the sequence.

  • The sequence is unlogged and the server is a standby.

close