pg_sequences

A system catalogue view providing human-readable information about sequences

pg_sequences is a system catalogue view providing human-readable information about sequences. It is based on the underlying system catalogue table pg_sequence.

pg_sequences was introduced in PostgreSQL 10 (commit 1753b1b0).

Notes

Some of the column names returned by pg_sequences match those contained in the sequence relation prior to PostgreSQL 10. See pg_sequence for further information.

Definition by PostgreSQL version

pg_sequences (PostgreSQL 13)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          |
 sequencename  | name    |           |          |
 sequenceowner | name    |           |          |
 data_type     | regtype |           |          |
 start_value   | bigint  |           |          |
 min_value     | bigint  |           |          |
 max_value     | bigint  |           |          |
 increment_by  | bigint  |           |          |
 cycle         | boolean |           |          |
 cache_size    | bigint  |           |          |
 last_value    | bigint  |           |          |
    

Documentation: pg_sequences

pg_sequences (PostgreSQL 12)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          |
 sequencename  | name    |           |          |
 sequenceowner | name    |           |          |
 data_type     | regtype |           |          |
 start_value   | bigint  |           |          |
 min_value     | bigint  |           |          |
 max_value     | bigint  |           |          |
 increment_by  | bigint  |           |          |
 cycle         | boolean |           |          |
 cache_size    | bigint  |           |          |
 last_value    | bigint  |           |          |
    

Documentation: pg_sequences

pg_sequences (PostgreSQL 11)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          |
 sequencename  | name    |           |          |
 sequenceowner | name    |           |          |
 data_type     | regtype |           |          |
 start_value   | bigint  |           |          |
 min_value     | bigint  |           |          |
 max_value     | bigint  |           |          |
 increment_by  | bigint  |           |          |
 cycle         | boolean |           |          |
 cache_size    | bigint  |           |          |
 last_value    | bigint  |           |          |
    

Documentation: pg_sequences

pg_sequences (PostgreSQL 10)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          |
 sequencename  | name    |           |          |
 sequenceowner | name    |           |          |
 data_type     | regtype |           |          |
 start_value   | bigint  |           |          |
 min_value     | bigint  |           |          |
 max_value     | bigint  |           |          |
 increment_by  | bigint  |           |          |
 cycle         | boolean |           |          |
 cache_size    | bigint  |           |          |
 last_value    | bigint  |           |          |
    

Documentation: pg_sequences

Change history

This view has not been modified since it was introduced in PostgreSQL 10.

Examples

postgres=# CREATE SEQUENCE foo;
CREATE SEQUENCE
postgres=# SELECT * FROM pg_sequences WHERE sequencename='foo';
-[ RECORD 1 ]-+--------------------
schemaname    | public
sequencename  | foo
sequenceowner | postgres
data_type     | bigint
start_value   | 1
min_value     | 1
max_value     | 9223372036854775807
increment_by  | 1
cycle         | f
cache_size    | 1
last_value    | 

Categories

DDL, Sequences, System catalogue

See also

pg_sequence, CREATE SEQUENCE, pg_get_serial_sequence()