Skip to main content

SHOW SEQUENCES

Introduced or updated: v1.2.742

Returns a list of the created sequences.

Syntax

SHOW SEQUENCES [ LIKE '<pattern>' | WHERE <expr> ]
ParameterDescription
LIKEFilters the results by their names using case-sensitive pattern matching.
WHEREFilters the results using an expression in the WHERE clause. You can filter based on any column in the result set, such as name, start, interval, current, created_on, updated_on, or comment. For example: WHERE start > 0 or WHERE name LIKE 's%'.

Examples

-- Create a sequence
CREATE SEQUENCE seq;

-- Show all sequences
SHOW SEQUENCES;

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ name │ startintervalcurrent │ created_on │ updated_on │ comment
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
│ seq │ 1112025-05-20 02:48:49.7493382025-05-20 02:48:49.749338NULL
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

-- 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 │ startintervalcurrent │ created_on │ updated_on │ comment
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

-- Filter sequences using WHERE clause
SHOW SEQUENCES WHERE start > 0;

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ name │ startintervalcurrent │ created_on │ updated_on │ comment
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

-- Filter sequences by name pattern
SHOW SEQUENCES LIKE 's%';

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ name │ startintervalcurrent │ created_on │ updated_on │ comment
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today