RENAME TABLE

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

语法图

RenameTableStmt:

RenameTableStmt

TableToTable:

TableToTable

示例

  1. mysql> CREATE TABLE t1 (a int);
  2. Query OK, 0 rows affected (0.12 sec)
  3. mysql> SHOW TABLES;
  4. +----------------+
  5. | Tables_in_test |
  6. +----------------+
  7. | t1 |
  8. +----------------+
  9. 1 row in set (0.00 sec)
  10. mysql> RENAME TABLE t1 TO t2;
  11. Query OK, 0 rows affected (0.08 sec)
  12. mysql> SHOW TABLES;
  13. +----------------+
  14. | Tables_in_test |
  15. +----------------+
  16. | t2 |
  17. +----------------+
  18. 1 row in set (0.00 sec)

MySQL 兼容性

RENAME TABLE 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue

另请参阅