title: SEQUENCES summary: 了解 information_schema 表 SEQUENCES

SEQUENCES

SEQUENCES 表提供了有关序列的信息。TiDB 中序列的功能是参照 MariaDB 中的类似功能来实现的。

  1. USE information_schema;
  2. DESC sequences;
  1. +-----------------+--------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +-----------------+--------------+------+------+---------+-------+
  4. | TABLE_CATALOG | varchar(512) | NO | | NULL | |
  5. | SEQUENCE_SCHEMA | varchar(64) | NO | | NULL | |
  6. | SEQUENCE_NAME | varchar(64) | NO | | NULL | |
  7. | CACHE | tinyint(4) | NO | | NULL | |
  8. | CACHE_VALUE | bigint(21) | YES | | NULL | |
  9. | CYCLE | tinyint(4) | NO | | NULL | |
  10. | INCREMENT | bigint(21) | NO | | NULL | |
  11. | MAX_VALUE | bigint(21) | YES | | NULL | |
  12. | MIN_VALUE | bigint(21) | YES | | NULL | |
  13. | START | bigint(21) | YES | | NULL | |
  14. | COMMENT | varchar(64) | YES | | NULL | |
  15. +-----------------+--------------+------+------+---------+-------+
  16. 11 rows in set (0.00 sec)
  1. CREATE SEQUENCE test.seq;
  2. SELECT nextval(test.seq);
  3. SELECT * FROM sequences\G
  1. +-------------------+
  2. | nextval(test.seq) |
  3. +-------------------+
  4. | 1 |
  5. +-------------------+
  6. 1 row in set (0.01 sec)
  7. *************************** 1. row ***************************
  8. TABLE_CATALOG: def
  9. SEQUENCE_SCHEMA: test
  10. SEQUENCE_NAME: seq
  11. CACHE: 1
  12. CACHE_VALUE: 1000
  13. CYCLE: 0
  14. INCREMENT: 1
  15. MAX_VALUE: 9223372036854775806
  16. MIN_VALUE: 1
  17. START: 1
  18. COMMENT:
  19. 1 row in set (0.00 sec)