Skip to content

sys.sequence

This view captures information about the sequences that exist in the system. See Generating Values with Sequences.

Column NameData TypeDescription
database_idbigintThe unique ID for the database.
schema_idbigintThe unique schema ID for the sequence.
sequence_idbigintThe unique ID for the sequence.
namenameThe user-defined name of the sequence.
fullnametextThe user-defined name of the sequence, pre-pended with the schema name.
start_valuebigintThe current starting value for the sequence.
last_valuebigintThe last_value reported in this column is calculated as follows:
last_value = ([NEXTVAL](../ybd_sqlref/nextval.md)(‘my_seq_name’) - [sys.worker\_id\(\)](../ybd_sqlref/sys.worker_id.md)) / 1024


where 1024 is the maximum number of workers.

For example, if last_value reports 49:


49 = (51199 - 1023) / 1024


where NEXTVAL for the sequence returns 51199 and sys.worker_id() returns 1023.

min_valuebigintThe minimum value that the sequence can generate.
max_valuebigintThe maximum value that the sequence can generate.
is_tempbooleanWhether the sequence was created as a temporary sequence (f=persistent; t=temporary).
creation_timetimestamptzWhen the sequence was created.

Example

premdb=# create sequence matchid start 50000;
CREATE SEQUENCE
premdb=> select * from sys.sequence;
 database_id | schema_id | sequence_id | owner_id |  name   |    fullname    | start_value | last_value |      min_value       |      max_value      | is_temp |         creation_time         
-------------+-----------+-------------+----------+---------+----------------+-------------+------------+----------------------+---------------------+---------+-------------------------------
      16400 |     24638 |       25507 |    25048 | matchid | premdb.matchid |          49 |         49 | -9223372036854775807 | 9223372036854775807 | f       | 2022-09-13 14:05:13.911498-07
(1 row)

premdb=> select nextval('matchid');
 nextval 
---------
   51199
(1 row)

Parent topic:System Views