Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.29 KB

sql-statement-rename-table.md

File metadata and controls

55 lines (41 loc) · 1.29 KB
title summary aliases
RENAME TABLE | TiDB SQL Statement Reference
An overview of the usage of RENAME TABLE for the TiDB database.
/docs/dev/sql-statements/sql-statement-rename-table/
/docs/dev/reference/sql/statements/rename-table/

RENAME TABLE

This statement renames an existing table to a new name.

Synopsis

RenameTableStmt ::=
    'RENAME' 'TABLE' TableToTable ( ',' TableToTable )*

TableToTable ::=
    TableName 'TO' TableName

Examples

mysql> CREATE TABLE t1 (a int);
Query OK, 0 rows affected (0.12 sec)

mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| t1             |
+----------------+
1 row in set (0.00 sec)

mysql> RENAME TABLE t1 TO t2;
Query OK, 0 rows affected (0.08 sec)

mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| t2             |
+----------------+
1 row in set (0.00 sec)

MySQL compatibility

The RENAME TABLE statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also