Skip to content

Commit 83c43ae

Browse files
authored
sequence: SHOW SEQUENCES and DESC SEQUENCE (#2202)
* add desc and show sequence * sequence: show and desc sequence * ddl index.md add more category
1 parent b033baf commit 83c43ae

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: DESC SEQUENCE
3+
sidebar_position: 4
4+
---
5+
6+
import FunctionDescription from '@site/src/components/FunctionDescription';
7+
8+
<FunctionDescription description="Introduced or updated: v1.2.742"/>
9+
10+
Describes the properties of a sequence.
11+
12+
## Syntax
13+
14+
```sql
15+
DESC SEQUENCE <sequence_name>
16+
```
17+
18+
| Parameter | Description |
19+
|----------------|-----------------------------------------------------------------------------------------------------------------------------|
20+
| sequence_name | The name of the sequence to describe. This will display all properties of the sequence including start value, interval, current value, creation timestamp, last update timestamp, and any comment. |
21+
22+
## Examples
23+
24+
```sql
25+
-- Create a sequence
26+
CREATE SEQUENCE seq;
27+
28+
-- Use the sequence in an INSERT statement
29+
CREATE TABLE tmp(a int, b uint64, c int);
30+
INSERT INTO tmp select 10,nextval(seq),20 from numbers(3);
31+
32+
-- Describe the sequence
33+
DESC SEQUENCE seq;
34+
35+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
36+
│ name │ start │ interval │ current │ created_on │ updated_on │ comment │
37+
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
38+
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
39+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: SHOW SEQUENCES
3+
sidebar_position: 3
4+
---
5+
6+
import FunctionDescription from '@site/src/components/FunctionDescription';
7+
8+
<FunctionDescription description="Introduced or updated: v1.2.742"/>
9+
10+
Returns a list of the created sequences.
11+
12+
## Syntax
13+
14+
```sql
15+
SHOW SEQUENCES [ LIKE '<pattern>' | WHERE <expr> ]
16+
```
17+
18+
| Parameter | Description |
19+
|-----------|-----------------------------------------------------------------------------------------------------------------------------|
20+
| LIKE | Filters the results by their names using case-sensitive pattern matching. |
21+
| WHERE | Filters 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%'`. |
22+
23+
## Examples
24+
25+
```sql
26+
-- Create a sequence
27+
CREATE SEQUENCE seq;
28+
29+
-- Show all sequences
30+
SHOW SEQUENCES;
31+
32+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
33+
│ name │ start │ interval │ current │ created_on │ updated_on │ comment │
34+
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
35+
│ seq │ 1112025-05-20 02:48:49.7493382025-05-20 02:48:49.749338NULL
36+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
37+
38+
-- Use the sequence in an INSERT statement
39+
CREATE TABLE tmp(a int, b uint64, c int);
40+
INSERT INTO tmp select 10,nextval(seq),20 from numbers(3);
41+
42+
-- Show sequences after usage
43+
SHOW SEQUENCES;
44+
45+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
46+
│ name │ start │ interval │ current │ created_on │ updated_on │ comment │
47+
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
48+
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
49+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
50+
51+
-- Filter sequences using WHERE clause
52+
SHOW SEQUENCES WHERE start > 0;
53+
54+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
55+
│ name │ start │ interval │ current │ created_on │ updated_on │ comment │
56+
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
57+
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
58+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
59+
60+
-- Filter sequences by name pattern
61+
SHOW SEQUENCES LIKE 's%';
62+
63+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
64+
│ name │ start │ interval │ current │ created_on │ updated_on │ comment │
65+
├────────┼────────┼──────────┼─────────┼────────────────────────────┼────────────────────────────┼──────────────────┤
66+
│ seq │ 1142025-05-20 02:48:49.7493382025-05-20 02:49:14.302917NULL
67+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

docs/en/sql-reference/10-sql-commands/00-ddl/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,44 @@ These topics provide reference information for the DDL (Data Definition Language
99
- [Database](00-database/index.md)
1010
- [Table](01-table/index.md)
1111
- [View](05-view/index.md)
12+
- [Dictionary](17-dictionary/index.md)
1213

1314
## Database Performance and Indexing
1415

1516
- [Cluster Key](06-clusterkey/index.md)
1617
- [Aggregating Index](07-aggregating-index/index.md)
18+
- [Inverted Index](07-inverted-index/index.md)
19+
- [Ngram Index](07-ngram-index/index.md)
20+
- [Virtual Column](07-virtual-column/index.md)
1721

1822
## User, Role, and Security Management
1923

2024
- [User](02-user/index.md)
2125
- [Network Policy](12-network-policy/index.md)
2226
- [Mask Policy](12-mask-policy/index.md)
27+
- [Password Policy](12-password-policy/index.md)
2328

2429
## Data Staging and Processing
2530

2631
- [Stage](03-stage/index.md)
2732
- [Stream](04-stream/index.md)
33+
- [Sequence](04-sequence/index.md)
34+
- [Task](04-task/index.md)
2835
- [Connection](13-connection/index.md)
2936
- [File Format](13-file-format/index.md)
3037

38+
## Transaction and Variable Management
39+
40+
- [Transaction](14-transaction/index.md)
41+
- [Variable](15-variable/index.md)
42+
3143
## Function and External Integration
3244

3345
- [UDF (User Defined Function)](10-udf/index.md)
3446
- [External Function](11-external-function/index.md)
47+
- [Procedure](18-procedure/index.md)
48+
- [Notification](16-notification/index.md)
49+
50+
## Compute Resource Management
51+
52+
- [Warehouse](19-warehouse/index.md)

0 commit comments

Comments
 (0)