After creating a sequence, you can view it using the SHOW SEQUENCES statement or a view.
View sequences using the SHOW SEQUENCES statement
The SHOW SEQUENCES statement allows you to view all sequences created in the current tenant.
The statement is as follows:
obclient> SHOW SEQUENCES
[LIKE expression
| LIKE expression IN database_name
| IN database_name
| WHERE sequence_name='sequence_name'
];
The parameters are described as follows:
LIKE expression: Specifies the information about the sequence name to be queried.IN database_name: Specifies the database to which the sequence to be queried belongs.WHERE sequence_name='sequence_name': Specifies the name of the sequence to be queried.
Examples:
View all sequences created in the current tenant.
obclient> SHOW SEQUENCES; +-------------------+ | Sequences_in_test | +-------------------+ | seq1 | | meq2 | +-------------------+ 2 rows in setView all sequences whose names contain the character
s.obclient> SHOW SEQUENCES LIKE '%s%'; +-------------------------+ | Sequences_in_test (%s%) | +-------------------------+ | seq1 | +-------------------------+ 1 rows in setView all sequences in the
testdatabase.obclient> SHOW SEQUENCES IN test; +-------------------+ | Sequences_in_test | +-------------------+ | seq1 | | meq2 | +-------------------+ 2 rows in setView the sequence named
seq1in the current tenant.obclient> SHOW SEQUENCES WHERE sequence_name='seq1'; +-------------------+ | Sequences_in_test | +-------------------+ | seq1 | +-------------------+ 1 row in set
View sequences using a view
You can query the oceanbase.DBA_OB_SEQUENCE_OBJECTS view to view all sequence information in the current tenant, including the sequence ID, sequence name, database to which the sequence belongs, start value, increment step, cycle attribute, and maximum and minimum values of the sequence.
A sample query is as follows:
obclient> SELECT * FROM oceanbase.DBA_OB_SEQUENCE_OBJECTS;
+-------------+------------------+-------------+---------------+-----------+-----------+--------------+------------+------------+------------+------------+---------------------+
| SEQUENCE_ID | SCHEMA_VERSION | DATABASE_ID | SEQUENCE_NAME | MIN_VALUE | MAX_VALUE | INCREMENT_BY | START_WITH | CACHE_SIZE | ORDER_FLAG | CYCLE_FLAG | IS_SYSTEM_GENERATED |
+-------------+------------------+-------------+---------------+-----------+-----------+--------------+------------+------------+------------+------------+---------------------+
| 500003 | 1675748057234736 | 500002 | seq1 | 1 | 10 | 2 | 1 | 30 | 0 | 0 | 0 |
+-------------+------------------+-------------+---------------+-----------+-----------+--------------+------------+------------+------------+------------+---------------------+
1 row in set
For more information about the fields in the oceanbase.DBA_OB_SEQUENCE_OBJECTS view, see oceanbase.DBA_OB_SEQUENCE_OBJECTS.
References
For more information about sequences, see the following topics: