本文主要介绍如何查询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                                      |
    +-------------+-----------+-------+------------+------------+------------+--------------+------------+---------------------+-------+-------+------------------------------------------+