本文主要介紹如何查詢Sequence信息。

語法

SHOW SEQUENCES [ WHERE <filter_condition> ]
說明
  • SHOW SEQUENCES僅顯示當前數據庫下的Sequence;
  • 支持通過INFORMATION_SCHEMA.SEQUENCES查詢實例范圍內所有的Sequence。

示例

  • 查看當前數據庫下的所有Sequence信息:
    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                                      |
    +-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+
  • 查看當前數據庫下的所有New Sequence信息:
    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 |
    +-------------+---------+-------+------------+------------+------------+--------------+------------+---------------------+-------+------+------------------------------------------+
  • 查看當前數據庫下的名字中帶有seq1的所有Sequence:
    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                                      |
    +-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+