From daaa7b128807be7c5be5f0342bb77852e5c9ad86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 22:07:23 +0200 Subject: [PATCH 1/2] ebnf show table next rowid --- .../sql-statement-show-table-next-rowid.md | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sql-statements/sql-statement-show-table-next-rowid.md b/sql-statements/sql-statement-show-table-next-rowid.md index 8dfa77d10e9c2..f4d6032642337 100644 --- a/sql-statements/sql-statement-show-table-next-rowid.md +++ b/sql-statements/sql-statement-show-table-next-rowid.md @@ -7,34 +7,29 @@ summary: Learn the usage of `SHOW TABLE NEXT_ROW_ID` in TiDB. `SHOW TABLE NEXT_ROW_ID` is used to show the details of some special columns of a table, including: -* `AUTO_INCREMENT` column automatically created by TiDB, namely, `_tidb_rowid` column. +* [`AUTO_INCREMENT`](/auto-increment.md) column automatically created by TiDB, namely, `_tidb_rowid` column. * `AUTO_INCREMENT` column created by users. * [`AUTO_RANDOM`](/auto-random.md) column created by users. * [`SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) created by users. ## Synopsis -**ShowTableNextRowIDStmt:** - -![ShowTableNextRowIDStmt](/media/sqlgram/ShowTableNextRowIDStmt.png) - -**TableName:** - -![TableName](/media/sqlgram/TableName.png) +```ebnf+diagram +ShowTableNextRowIDStmt ::= + "SHOW" "TABLE" (SchemaName ".")? TableName "NEXT_ROW_ID" +``` ## Examples For newly created tables, `NEXT_GLOBAL_ROW_ID` is `1` because no Row ID is allocated. -{{< 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 | +---------+------------+-------------+--------------------+ @@ -43,16 +38,16 @@ show table t next_row_id; 1 row in set (0.00 sec) ``` -Data have been written to the table. The TiDB server that inserts the data allocates and caches 30000 IDs at once. Thus, NEXT_GLOBAL_ROW_ID is 30001 now. +Data have been written to the table. The TiDB server that inserts the data allocates and caches 30000 IDs at once. Thus, NEXT_GLOBAL_ROW_ID is 30001 now. The number of IDs is controled by the [`AUTO_ID_CACHE`](/auto-increment.md#auto_id_cache). ```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 | +---------+------------+-------------+--------------------+ From e37ba22f7333cf9fff2a01ad7efcc6681b9a1c9e Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Mon, 22 Apr 2024 16:12:47 +0800 Subject: [PATCH 2/2] Update wording --- sql-statements/sql-statement-show-table-next-rowid.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-show-table-next-rowid.md b/sql-statements/sql-statement-show-table-next-rowid.md index f4d6032642337..d145df7b8ecd6 100644 --- a/sql-statements/sql-statement-show-table-next-rowid.md +++ b/sql-statements/sql-statement-show-table-next-rowid.md @@ -38,7 +38,7 @@ SHOW TABLE t NEXT_ROW_ID; 1 row in set (0.00 sec) ``` -Data have been written to the table. The TiDB server that inserts the data allocates and caches 30000 IDs at once. Thus, NEXT_GLOBAL_ROW_ID is 30001 now. The number of IDs is controled by the [`AUTO_ID_CACHE`](/auto-increment.md#auto_id_cache). +Data have been written to the table. The TiDB server that inserts the data allocates and caches 30000 IDs at once. Thus, NEXT_GLOBAL_ROW_ID is 30001 now. The number of IDs is controlled by [`AUTO_ID_CACHE`](/auto-increment.md#auto_id_cache). ```sql INSERT INTO t VALUES (), (), ();