SHOW SEQUENCES

更新时间:
复制 MD 格式

Lists the sequences in the current database, with optional filtering by name or type.

SHOW SEQUENCES returns only sequences in the current database. To query sequences across all databases in the instance, use the INFORMATION_SCHEMA.SEQUENCES view.

Syntax

SHOW SEQUENCES [ WHERE <filter_condition> ]

Result columns

Each row describes one sequence. Columns that do not apply to a sequence type appear as N/A in the result.

ColumnDescriptionDefaultApplies to
SCHEMA_NAMEThe schema that owns the sequence.All types
NAMEThe sequence name.All types
VALUEThe last allocated value.NEW, GROUP
UNIT_COUNTThe number of allocation units.GROUP
UNIT_INDEXThe index of the current allocation unit.GROUP
INNER_STEPThe step size within each allocation unit.GROUP
INCREMENT_BYThe increment between consecutive values.NEW
START_WITHThe starting value.NEW
MAX_VALUEThe maximum value before the sequence cycles or stops.NEW
CYCLEWhether the sequence restarts after reaching MAX_VALUE. Y = restarts; N = stops.NEW
TYPEThe sequence type: NEW, TIME, or GROUP.All types
PHY_SEQ_NAMEThe internal physical sequence name.NEW

Examples

List all sequences

SHOW SEQUENCES;
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+
| SCHEMA_NAME | NAME      | VALUE | UNIT_COUNT | UNIT_INDEX | INNER_STEP | INCREMENT_BY | START_WITH | MAX_VALUE           | CYCLE | TYPE  | PHY_SEQ_NAME                             |
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+
| partest     | newseq1   | 1     | N/A        | N/A        | N/A        | 1            | 1          | 9223372036854775807 | N     | NEW   | pxc_seq_ee6653d17586a275d41522852aa36c80 |
| partest     | newseq2   | 1     | N/A        | N/A        | N/A        | 2            | 100        | 200                 | Y     | NEW   | pxc_seq_6a2a3689aa90a0179b71183b8bfc426c |
| partest     | timeseq1  | N/A   | N/A        | N/A        | N/A        | N/A          | N/A        | N/A                 | N/A   | TIME  | N/A                                      |
| partest     | timeseq2  | N/A   | N/A        | N/A        | N/A        | N/A          | N/A        | N/A                 | N/A   | TIME  | N/A                                      |
| partest     | groupseq1 | 0     | 1          | 0          | 100000     | N/A          | N/A        | N/A                 | N/A   | GROUP | N/A                                      |
| partest     | groupseq2 | 200000| 1          | 0          | 100000     | N/A          | N/A        | N/A                 | N/A   | GROUP | N/A                                      |
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+

Filter by type

Use the WHERE clause to narrow results to a specific sequence type.

SHOW SEQUENCES WHERE TYPE='NEW';
+-------------+---------+-------+------------+------------+------------+--------------+------------+---------------------+-------+------+------------------------------------------+
| SCHEMA_NAME | NAME    | VALUE | UNIT_COUNT | UNIT_INDEX | INNER_STEP | INCREMENT_BY | START_WITH | MAX_VALUE           | CYCLE | TYPE | PHY_SEQ_NAME                             |
+-------------+---------+-------+------------+------------+------------+--------------+------------+---------------------+-------+------+------------------------------------------+
| partest     | newseq1 | 1     | N/A        | N/A        | N/A        | 1            | 1          | 9223372036854775807 | N     | NEW  | pxc_seq_ee6653d17586a275d41522852aa36c80 |
| partest     | newseq2 | 1     | N/A        | N/A        | N/A        | 2            | 101        | 300                 | N     | NEW  | pxc_seq_6a2a3689aa90a0179b71183b8bfc426c |
+-------------+---------+-------+------------+------------+------------+--------------+------------+---------------------+-------+------+------------------------------------------+

Filter by name

SHOW SEQUENCES WHERE NAME LIKE '%seq1%';
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+
| SCHEMA_NAME | NAME      | VALUE | UNIT_COUNT | UNIT_INDEX | INNER_STEP | INCREMENT_BY | START_WITH | MAX_VALUE           | CYCLE | TYPE  | PHY_SEQ_NAME                             |
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+
| partest     | newseq1   | 1     | N/A        | N/A        | N/A        | 1            | 1          | 9223372036854775807 | N     | NEW   | pxc_seq_ee6653d17586a275d41522852aa36c80 |
| partest     | timeseq1  | N/A   | N/A        | N/A        | N/A        | N/A          | N/A        | N/A                 | N/A   | TIME  | N/A                                      |
| partest     | groupseq1 | 0     | 1          | 0          | 100000     | N/A          | N/A        | N/A                 | N/A   | GROUP | N/A                                      |
+-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+