Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql-stmt: update synopsis to ebnf diagrams for 6 statements #17211

Merged
merged 3 commits into from May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 9 additions & 14 deletions sql-statements/sql-statement-show-create-table.md
Expand Up @@ -10,13 +10,10 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-create-table/','/docs-

## 语法图

**ShowCreateTableStmt:**

![ShowCreateTableStmt](/media/sqlgram/ShowCreateTableStmt.png)

**TableName:**

![TableName](/media/sqlgram/TableName.png)
```ebnf+diagram
ShowCreateTableStmt ::=
"SHOW" "CREATE" "TABLE" (SchemaName ".")? TableName
```

## 示例

Expand All @@ -33,17 +30,15 @@ Query OK, 0 rows affected (0.12 sec)
{{< copyable "sql" >}}

```sql
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t1\G
```

```
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.00 sec)
```

Expand Down
29 changes: 11 additions & 18 deletions sql-statements/sql-statement-show-indexes.md
Expand Up @@ -10,25 +10,14 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-indexes/','/docs-cn/de

## 语法图

**ShowIndexStmt:**
```ebnf+diagram
ShowIndexStmt ::=
"SHOW" ( "INDEX" | "INDEXES" | "KEYS" ) ("FROM" | "IN" ) TableName (("FROM" | "IN") SchemaName )? ShowLikeOrWhere?

![ShowIndexStmt](/media/sqlgram/ShowIndexStmt.png)

**ShowIndexKwd:**

![ShowIndexKwd](/media/sqlgram/ShowIndexKwd.png)

**FromOrIn:**

![FromOrIn](/media/sqlgram/FromOrIn.png)

**TableName:**

![TableName](/media/sqlgram/TableName.png)

**ShowLikeOrWhereOpt:**

![ShowLikeOrWhereOpt](/media/sqlgram/ShowLikeOrWhereOpt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

Expand Down Expand Up @@ -99,3 +88,7 @@ SHOW KEYS FROM t1;
* [SHOW CREATE TABLE](/sql-statements/sql-statement-show-create-table.md)
* [DROP INDEX](/sql-statements/sql-statement-drop-index.md)
* [CREATE INDEX](/sql-statements/sql-statement-create-index.md)
* [`information_schema.TIDB_INDEXES`](/information-schema/information-schema-tidb-indexes.md)
* [`information_schema.TIDB_INDEX_USAGE`](/information-schema/information-schema-tidb-index-usage.md)
* [`information_schema.KEY_COLUMN_USAGE`](/information-schema/information-schema-key-column-usage.md)
* [`sys.schema_unused_indexes`](/sys-schema/sys-schema-unused-indexes.md)
25 changes: 12 additions & 13 deletions sql-statements/sql-statement-show-table-next-rowid.md
Expand Up @@ -8,20 +8,17 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-table-next-rowid/']

`SHOW TABLE NEXT_ROW_ID` 语句用于显示用户表中某些特殊列的详情,主要包含以下几种类型:

* TiDB 创建的 `AUTO_INCREMENT` 类型列,即 `_tidb_rowid` 列
* TiDB 创建的 [`AUTO_INCREMENT`](/auto-increment.md) 类型列,即 `_tidb_rowid` 列
* 用户创建的 `AUTO_INCREMENT` 类型列
* 用户创建的 [`AUTO_RANDOM`](/auto-random.md) 类型列
* 用户创建的 [`SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) 对象信息

## 语法图

**ShowTableNextRowIDStmt:**

![ShowTableNextRowIDStmt](/media/sqlgram/ShowTableNextRowIDStmt.png)

**TableName:**

![TableName](/media/sqlgram/TableName.png)
```ebnf+diagram
ShowTableNextRowIDStmt ::=
"SHOW" "TABLE" (SchemaName ".")? TableName "NEXT_ROW_ID"
```

## 示例

Expand All @@ -30,12 +27,12 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-table-next-rowid/']
{{< copyable "sql" >}}

```sql
create table t(a int);
CREATE TABLE t(a int);
Query OK, 0 rows affected (0.06 sec)
```

```sql
show table t next_row_id;
SHOW TABLE t NEXT_ROW_ID;
+---------+------------+-------------+--------------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID |
+---------+------------+-------------+--------------------+
Expand All @@ -44,16 +41,18 @@ show table t next_row_id;
1 row in set (0.00 sec)
```

下面示例中,表中写入了数据,负责写入的 TiDB Server 一次性向存储层请求了 30000 个 ID 缓存起来,NEXT_GLOBAL_ROW_ID 值为 `30001`。
下面示例中,表中写入了数据,负责写入的 TiDB Server 一次性向存储层请求了 30000 个 ID 缓存起来,NEXT_GLOBAL_ROW_ID 值为 `30001`。ID 的数量由 [`AUTO_ID_CACHE`](/auto-increment.md#auto_id_cache) 控制。

{{< copyable "sql" >}}

```sql
insert into t values (), (), ();
INSERT INTO t VALUES (), (), ();
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
```

```sql
show table t next_row_id;
SHOW TABLE t NEXT_ROW_ID;
+---------+------------+-------------+--------------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID |
+---------+------------+-------------+--------------------+
Expand Down
32 changes: 10 additions & 22 deletions sql-statements/sql-statement-show-table-regions.md
Expand Up @@ -18,25 +18,13 @@ SHOW TABLE [table_name] INDEX [index_name] REGIONS [WhereClauseOptional];

### 语法图

**ShowTableRegionStmt:**
```ebnf+diagram
ShowTableRegionStmt ::=
"SHOW" "TABLE" TableName PartitionNameList? ("INDEX" IndexName)? "REGIONS" ("WHERE" Expression)?

![ShowTableRegionStmt](/media/sqlgram/ShowTableRegionStmt.png)

**TableName:**

![TableName](/media/sqlgram/TableName.png)

**PartitionNameListOpt:**

![PartitionNameListOpt](/media/sqlgram/PartitionNameListOpt.png)

**WhereClauseOptional:**

![WhereClauseOptional](/media/sqlgram/WhereClauseOptional.png)

**WhereClause:**

![WhereClause](/media/sqlgram/WhereClause.png)
TableName ::=
(SchemaName ".")? Identifier
```

`SHOW TABLE REGIONS` 会返回如下列:

Expand Down Expand Up @@ -152,7 +140,7 @@ SHOW TABLE t1 REGIONS;
{{< copyable "sql" >}}

```sql
show table t regions;
SHOW TABLE t REGIONS;
```

```sql
Expand All @@ -179,7 +167,7 @@ show table t regions;
{{< copyable "sql" >}}

```sql
show table t regions where leader_store_id =1;
SHOW TABLE t REGIONS WHERE leader_store_id =1;
```

```
Expand All @@ -195,7 +183,7 @@ show table t regions where leader_store_id =1;
{{< copyable "sql" >}}

```sql
split table t index name between ("a") and ("z") regions 2;
SPLIT TABLE t INDEX name BETWEEN ("a") AND ("z") REGIONS 2;
```

```
Expand All @@ -212,7 +200,7 @@ split table t index name between ("a") and ("z") regions 2;
{{< copyable "sql" >}}

```sql
show table t regions;
SHOW TABLE t REGIONS;
```

```
Expand Down