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

update several sql statements docs #3299

Merged
merged 3 commits into from
May 25, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified media/sqlgram/FromOrIn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/sqlgram/OptFull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/Railroad-Diagram-Generator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/sqlgram/ShowDatabaseNameOpt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/ShowProcesslistStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/ShowTableNextRowIDStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/ShowTableStatusStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/ShowWarningsStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/StatusTableName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/sqlgram/TableName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/sqlgram/rr-1.62.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions sql-statements/sql-statement-show-processlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand All @@ -39,7 +39,7 @@ SHOW PROCESSLIST;

## MySQL 兼容性

* TiDB 中的 `State` 列是非描述性的。在 TiDB 中,将状态表示为单个值更复杂,因为查询是并行执行的,而且每个 GO 线程在任一时刻都有不同的状态。
* TiDB 中的 `State` 列是非描述性的。在 TiDB 中,将状态表示为单个值更复杂,因为查询是并行执行的,而且每个 Go 线程在任一时刻都有不同的状态。

## 另请参阅

Expand Down
64 changes: 64 additions & 0 deletions sql-statements/sql-statement-show-table-next-rowid.md
Original file line number Diff line number Diff line change
@@ -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 特有的语法。
12 changes: 6 additions & 6 deletions sql-statements/sql-statement-show-table-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 示例

Expand Down
8 changes: 2 additions & 6 deletions sql-statements/sql-statement-show-warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 示例

Expand Down