Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 1.34 KB

sql-statement-rename-table.md

File metadata and controls

81 lines (59 loc) · 1.34 KB
title summary aliases
RENAME TABLE
TiDB 数据库中 RENAME TABLE 的使用概况。
/docs-cn/dev/sql-statements/sql-statement-rename-table/
/docs-cn/dev/reference/sql/statements/rename-table/

RENAME TABLE

RENAME TABLE 语句用于对已有表进行重命名。

语法图

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

TableToTable ::=
    TableName 'TO' TableName

示例

{{< copyable "sql" >}}

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

{{< copyable "sql" >}}

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

{{< copyable "sql" >}}

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

{{< copyable "sql" >}}

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

MySQL 兼容性

RENAME TABLE 语句与 MySQL 完全兼容。如发现任何兼容性差异,请尝试 TiDB 支持资源

另请参阅