| title | summary | aliases | |
|---|---|---|---|
SHOW TABLE NEXT_ROW_ID |
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_INCREMENTcolumn automatically created by TiDB, namely,_tidb_rowidcolumn.AUTO_INCREMENTcolumn created by users.AUTO_RANDOMcolumn created by users.SEQUENCEcreated by users.
ShowTableNextRowIDStmt:
TableName:
For newly created tables, NEXT_GLOBAL_ROW_ID is 1 because no Row ID is allocated.
{{< copyable "sql" >}}
create table t(a int);
Query OK, 0 rows affected (0.06 sec)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)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.
insert into t values (), (), ();
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0show table t next_row_id;
+---------+------------+-------------+--------------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID |
+---------+------------+-------------+--------------------+
| test | t | _tidb_rowid | 30001 |
+---------+------------+-------------+--------------------+
1 row in set (0.00 sec)This statement is a TiDB extension to MySQL syntax.

