Skip to content

Commit 6108387

Browse files
sundy-lib41sh
andauthored
docs: add show create dictionary sql reference (#3158)
Co-authored-by: baishen <baishen2009@gmail.com>
1 parent 450fde6 commit 6108387

4 files changed

Lines changed: 132 additions & 0 deletions

File tree

docs/cn/sql-reference/10-sql-commands/00-ddl/17-dictionary/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ Dictionary 提供了一种基于键值对的方法,用于从各种外部数据
1212
| [DROP DICTIONARY](drop-dictionary.md) | 删除字典 |
1313
| [RENAME DICTIONARY](rename-dictionary.md) | 重命名字典 |
1414

15+
## 字典信息
16+
17+
| 命令 | 描述 |
18+
|---------|-------------|
19+
| [SHOW CREATE DICTIONARY](show-create-dictionary.md) | 显示字典的 CREATE 语句 |
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: SHOW CREATE DICTIONARY
3+
sidebar_position: 4
4+
---
5+
6+
显示用于创建字典的 SQL 语句。
7+
8+
## 语法
9+
10+
```sql
11+
SHOW CREATE DICTIONARY [ <catalog_name>. ][ <database_name>. ]<dictionary_name>
12+
```
13+
14+
## 参数
15+
16+
| 参数 | 说明 |
17+
|-----------|-------------|
18+
| `<dictionary_name>` | 字典名称。可以带上 catalog 和 database 限定。 |
19+
20+
## 输出
21+
22+
结果会返回字典名称以及重建后的 `CREATE DICTIONARY` 语句。
23+
24+
`password` 这样的敏感 source 选项会在返回的 SQL 中被掩盖。
25+
26+
## 示例
27+
28+
```sql
29+
CREATE DICTIONARY user_info
30+
(
31+
user_id UInt64,
32+
user_name String,
33+
user_email String
34+
)
35+
PRIMARY KEY user_id
36+
SOURCE(
37+
mysql(
38+
host = '127.0.0.1'
39+
port = '3306'
40+
username = 'root'
41+
password = 'root'
42+
db = 'app'
43+
table = 'users'
44+
)
45+
)
46+
COMMENT 'User dictionary from MySQL';
47+
48+
SHOW CREATE DICTIONARY user_info;
49+
50+
*************************** 1. row ***************************
51+
Dictionary: user_info
52+
Create Dictionary: CREATE DICTIONARY user_info
53+
(
54+
user_id BIGINT UNSIGNED NULL,
55+
user_name VARCHAR NULL,
56+
user_email VARCHAR NULL
57+
)
58+
PRIMARY KEY user_id
59+
SOURCE(mysql(db='app' host='127.0.0.1' password='[HIDDEN]' port='3306' table='users' username='root'))
60+
COMMENT 'User dictionary from MySQL'
61+
```

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ Dictionary provides a key-value approach for reading data from various external
1212
| [DROP DICTIONARY](drop-dictionary.md) | Deletes a dictionary |
1313
| [RENAME DICTIONARY](rename-dictionary.md) | Renames a dictionary |
1414

15+
## Dictionary Information
16+
17+
| Command | Description |
18+
|---------|-------------|
19+
| [SHOW CREATE DICTIONARY](show-create-dictionary.md) | Shows the CREATE statement for a dictionary |
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: SHOW CREATE DICTIONARY
3+
sidebar_position: 4
4+
---
5+
6+
Shows the SQL statement used to create a dictionary.
7+
8+
## Syntax
9+
10+
```sql
11+
SHOW CREATE DICTIONARY [ <catalog_name>. ][ <database_name>. ]<dictionary_name>
12+
```
13+
14+
## Parameters
15+
16+
| Parameter | Description |
17+
|-----------|-------------|
18+
| `<dictionary_name>` | The dictionary name. You can qualify it with catalog and database names. |
19+
20+
## Output
21+
22+
The result contains the dictionary name and the reconstructed `CREATE DICTIONARY` statement.
23+
24+
Sensitive source options such as `password` are masked in the returned SQL.
25+
26+
## Examples
27+
28+
```sql
29+
CREATE DICTIONARY user_info
30+
(
31+
user_id UInt64,
32+
user_name String,
33+
user_email String
34+
)
35+
PRIMARY KEY user_id
36+
SOURCE(
37+
mysql(
38+
host = '127.0.0.1'
39+
port = '3306'
40+
username = 'root'
41+
password = 'root'
42+
db = 'app'
43+
table = 'users'
44+
)
45+
)
46+
COMMENT 'User dictionary from MySQL';
47+
48+
SHOW CREATE DICTIONARY user_info;
49+
50+
*************************** 1. row ***************************
51+
Dictionary: user_info
52+
Create Dictionary: CREATE DICTIONARY user_info
53+
(
54+
user_id BIGINT UNSIGNED NULL,
55+
user_name VARCHAR NULL,
56+
user_email VARCHAR NULL
57+
)
58+
PRIMARY KEY user_id
59+
SOURCE(mysql(db='app' host='127.0.0.1' password='[HIDDEN]' port='3306' table='users' username='root'))
60+
COMMENT 'User dictionary from MySQL'
61+
```

0 commit comments

Comments
 (0)