Sequence relation

A special single-row table containing metadata about a sequence

A sequence relation is a special single-row table containing metadata about a sequence.

The sequence relation's relkind in pg_class is S.

Notes

In PostgreSQL 9.6 and earlier, all information about the sequence was stored in the sequence relation. From PostgreSQL 10, all metadata not changed by nextval() is contained in the system catalogue table pg_sequence; see that entry for further details.

Examples

From PostgreSQL 10 and later:

postgres=# CREATE SEQUENCE foo;
CREATE SEQUENCE
postgres=# SELECT * from public.foo;
 last_value | log_cnt | is_called 
------------+---------+-----------
          1 |       0 | f
(1 row)

In PostgreSQL 9.6 and earlier:

postgres=# CREATE SEQUENCE foo;
CREATE SEQUENCE
postgres=# SELECT * from public.foo;
-[ RECORD 1 ]-+--------------------
sequence_name | foo
last_value    | 1
start_value   | 1
increment_by  | 1
max_value     | 9223372036854775807
min_value     | 1
cache_value   | 1
log_cnt       | 0
is_cycled     | f
is_called     | f

Categories

DDL, Sequences

See also

pg_sequence, pg_sequences, CREATE SEQUENCE