Appearance
sys.sequence
This view captures information about the sequences that exist in the system. See Generating Values with Sequences.
Column Name | Data Type | Description |
---|---|---|
database_id | bigint | The unique ID for the database. |
schema_id | bigint | The unique schema ID for the sequence. |
sequence_id | bigint | The unique ID for the sequence. |
name | name | The user-defined name of the sequence. |
fullname | text | The user-defined name of the sequence, pre-pended with the schema name. |
start_value | bigint | The current starting value for the sequence. |
last_value | bigint | The 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_value | bigint | The minimum value that the sequence can generate. |
max_value | bigint | The maximum value that the sequence can generate. |
is_temp | boolean | Whether the sequence was created as a temporary sequence (f =persistent; t =temporary). |
creation_time | timestamptz | When 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