📣
TiDB Cloud Premium 开放公测中。为企业级工作负载提供无限扩展、即时弹性伸缩和高级安全保障。此页面由 AI 自动翻译,英文原文请见此处。

SHOW SEQUENCES



返回已创建的序列列表。

语法

SHOW SEQUENCES [ LIKE '<pattern>' | WHERE <expr> ]
参数描述
LIKE使用大小写敏感的模式匹配按名称过滤结果。
WHERE使用 WHERE 子句中的表达式过滤结果。你可以基于结果集中的任意列进行过滤,例如 name、start、interval、current、created_on、updated_on 或 comment。例如:WHERE start > 0 或 WHERE name LIKE 's%'。

示例

-- Create a sequence CREATE SEQUENCE seq; -- Show all sequences SHOW SEQUENCES; ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ name │ start │ interval │ current │ created_on │ updated_on │ comment │ ├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤ │ seq │ 1 │ 1 │ 1 │ 2025-05-20 02:48:49.749338 │ 2025-05-20 02:48:49.749338 │ NULL │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -- Use the sequence in an INSERT statement CREATE TABLE tmp(a int, b uint64, c int); INSERT INTO tmp select 10,nextval(seq),20 from numbers(3); -- Show sequences after usage SHOW SEQUENCES; ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ name │ start │ interval │ current │ created_on │ updated_on │ comment │ ├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤ │ seq │ 1 │ 1 │ 4 │ 2025-05-20 02:48:49.749338 │ 2025-05-20 02:49:14.302917 │ NULL │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -- Filter sequences using WHERE clause SHOW SEQUENCES WHERE start > 0; ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ name │ start │ interval │ current │ created_on │ updated_on │ comment │ ├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤ │ seq │ 1 │ 1 │ 4 │ 2025-05-20 02:48:49.749338 │ 2025-05-20 02:49:14.302917 │ NULL │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -- Filter sequences by name pattern SHOW SEQUENCES LIKE 's%'; ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ name │ start │ interval │ current │ created_on │ updated_on │ comment │ ├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤ │ seq │ 1 │ 1 │ 4 │ 2025-05-20 02:48:49.749338 │ 2025-05-20 02:49:14.302917 │ NULL │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

文档内容是否有帮助?