diff --git a/media/sqlgram/FromOrIn.png b/media/sqlgram/FromOrIn.png index 76e1a24b016e..10344be9c607 100644 Binary files a/media/sqlgram/FromOrIn.png and b/media/sqlgram/FromOrIn.png differ diff --git a/media/sqlgram/OptFull.png b/media/sqlgram/OptFull.png index fd8db31c717f..d97f1913a25e 100644 Binary files a/media/sqlgram/OptFull.png and b/media/sqlgram/OptFull.png differ diff --git a/media/sqlgram/Railroad-Diagram-Generator.png b/media/sqlgram/Railroad-Diagram-Generator.png new file mode 100644 index 000000000000..d7fc4c9c91ac Binary files /dev/null and b/media/sqlgram/Railroad-Diagram-Generator.png differ diff --git a/media/sqlgram/ShowDatabaseNameOpt.png b/media/sqlgram/ShowDatabaseNameOpt.png index 93213f8360f7..09a6e2d85de8 100644 Binary files a/media/sqlgram/ShowDatabaseNameOpt.png and b/media/sqlgram/ShowDatabaseNameOpt.png differ diff --git a/media/sqlgram/ShowProcesslistStmt.png b/media/sqlgram/ShowProcesslistStmt.png new file mode 100644 index 000000000000..87bd25e3727f Binary files /dev/null and b/media/sqlgram/ShowProcesslistStmt.png differ diff --git a/media/sqlgram/ShowTableNextRowIDStmt.png b/media/sqlgram/ShowTableNextRowIDStmt.png new file mode 100644 index 000000000000..d226bb6c1379 Binary files /dev/null and b/media/sqlgram/ShowTableNextRowIDStmt.png differ diff --git a/media/sqlgram/ShowTableStatusStmt.png b/media/sqlgram/ShowTableStatusStmt.png new file mode 100644 index 000000000000..c80600ca1f3a Binary files /dev/null and b/media/sqlgram/ShowTableStatusStmt.png differ diff --git a/media/sqlgram/ShowWarningsStmt.png b/media/sqlgram/ShowWarningsStmt.png new file mode 100644 index 000000000000..6fb9c79daa84 Binary files /dev/null and b/media/sqlgram/ShowWarningsStmt.png differ diff --git a/media/sqlgram/StatusTableName.png b/media/sqlgram/StatusTableName.png new file mode 100644 index 000000000000..263fefd9b460 Binary files /dev/null and b/media/sqlgram/StatusTableName.png differ diff --git a/media/sqlgram/TableName.png b/media/sqlgram/TableName.png index 8f40d55f7ded..7d063393d640 100644 Binary files a/media/sqlgram/TableName.png and b/media/sqlgram/TableName.png differ diff --git a/media/sqlgram/rr-1.62.png b/media/sqlgram/rr-1.62.png index bae26a896a95..d7fc4c9c91ac 100644 Binary files a/media/sqlgram/rr-1.62.png and b/media/sqlgram/rr-1.62.png differ diff --git a/sql-statements/sql-statement-show-processlist.md b/sql-statements/sql-statement-show-processlist.md index 09acc66667bb..ac6ed7a44c29 100644 --- a/sql-statements/sql-statement-show-processlist.md +++ b/sql-statements/sql-statement-show-processlist.md @@ -11,9 +11,9 @@ aliases: ['/docs-cn/dev/reference/sql/statements/show-processlist/'] ## 语法图 -**ShowStmt:** +**ShowProcesslistStmt:** -![ShowStmt](/media/sqlgram/ShowStmt.png) +![ShowProcesslistStmt](/media/sqlgram/ShowProcesslistStmt.png) **OptFull:** @@ -39,7 +39,7 @@ SHOW PROCESSLIST; ## MySQL 兼容性 -* TiDB 中的 `State` 列是非描述性的。在 TiDB 中,将状态表示为单个值更复杂,因为查询是并行执行的,而且每个 GO 线程在任一时刻都有不同的状态。 +* TiDB 中的 `State` 列是非描述性的。在 TiDB 中,将状态表示为单个值更复杂,因为查询是并行执行的,而且每个 Go 线程在任一时刻都有不同的状态。 ## 另请参阅 diff --git a/sql-statements/sql-statement-show-table-next-rowid.md b/sql-statements/sql-statement-show-table-next-rowid.md new file mode 100644 index 000000000000..36271be993ff --- /dev/null +++ b/sql-statements/sql-statement-show-table-next-rowid.md @@ -0,0 +1,64 @@ +--- +title: SHOW TABLE NEXT_ROW_ID +summary: TiDB 数据库中 SHOW TABLE NEXT_ROW_ID 的使用概况。 +category: reference +aliases: ['/docs-cn/dev/reference/sql/statements/show-status/'] +--- + +# SHOW TABLE NEXT_ROW_ID + +`SHOW TABLE NEXT_ROW_ID` 语句用于查看 TiDB 中一张表的隐式分配的全局 Row ID 情况: + +- 对于大多数表,TiDB 会为每一条记录分配一个表内唯一的数字作为 ID,ID 最大分配值被持久化在存储层,每个 TiDB Server 会按需向持久层申请一段空间缓存在内存中,用于 ID 的分配。该语法用于查询存储层的所记录的下一个分配值。 +- 对于主键被定义为整数类型的表,由于 TiDB 进行了优化,将整数主键映射为了 Row ID,因此对于该类型的表,`SHOW TABLE NEXT_ROW_ID` 的值没有意义。 + +## 语法图 + +**ShowTableNextRowIDStmt:** + +![ShowTableNextRowIDStmt](/media/sqlgram/ShowTableNextRowIDStmt.png) + +**TableName:** + +![TableName](/media/sqlgram/TableName.png) + +## 示例 + +{{< copyable "sql" >}} + +```sql +create table t(a int); +Query OK, 0 rows affected (0.06 sec) +``` + +```sql +# 对于新建的表,由于没有任何的 Row ID 分配,NEXT_GLOBAL_ROW_ID 值为 1 +show table t next_row_id; ++---------+------------+-------------+--------------------+ +| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ++---------+------------+-------------+--------------------+ +| test | t | _tidb_rowid | 1 | ++---------+------------+-------------+--------------------+ +1 row in set (0.00 sec) +``` + +```sql +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; +# 表中写入了数据,负责写入的 TiDB Server 一次性向存储层请求了 30000 个 ID 缓存起来,NEXT_GLOBAL_ROW_ID 值为 30001 ++---------+------------+-------------+--------------------+ +| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ++---------+------------+-------------+--------------------+ +| test | t | _tidb_rowid | 30001 | ++---------+------------+-------------+--------------------+ +1 row in set (0.00 sec) +``` + +## MySQL 兼容性 + +`SHOW TABLE NEXT_ROW_ID` 语句是 TiDB 特有的语法。 \ No newline at end of file diff --git a/sql-statements/sql-statement-show-table-status.md b/sql-statements/sql-statement-show-table-status.md index 718c0d234bbe..a4edb56b4760 100644 --- a/sql-statements/sql-statement-show-table-status.md +++ b/sql-statements/sql-statement-show-table-status.md @@ -11,17 +11,17 @@ aliases: ['/docs-cn/dev/reference/sql/statements/show-table-status/'] ## 语法图 -**ShowStmt:** +**ShowTableStatusStmt:** -![ShowStmt](/media/sqlgram/ShowStmt.png) +![ShowTableStatusStmt](/media/sqlgram/ShowTableStatusStmt.png) -**ShowTargetFilterable:** +**FromOrIn:** -![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) +![FromOrIn](/media/sqlgram/FromOrIn.png) -**ShowDatabaseNameOpt:** +**StatusTableName:** -![ShowDatabaseNameOpt](/media/sqlgram/ShowDatabaseNameOpt.png) +![StatusTableName](/media/sqlgram/StatusTableName.png) ## 示例 diff --git a/sql-statements/sql-statement-show-warnings.md b/sql-statements/sql-statement-show-warnings.md index 89eb1cec0235..b8ac11156ae6 100644 --- a/sql-statements/sql-statement-show-warnings.md +++ b/sql-statements/sql-statement-show-warnings.md @@ -11,13 +11,9 @@ aliases: ['/docs-cn/dev/reference/sql/statements/show-warnings/'] ## 语法图 -**ShowStmt:** +**ShowWarningsStmt:** -![ShowStmt](/media/sqlgram/ShowStmt.png) - -**ShowTargetFilterable:** - -![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) +![ShowWarningsStmt](/media/sqlgram/ShowWarningsStmt.png) ## 示例