MySQL Command rename the renametable syntax renametabletbl_nametonew_tbl_name [, tbl_name2tonew_tbl_na.
MySQL Command rename table syntax
Rename table tbl_name to new_tbl_name [, tbl_name2
New_tbl_name2,...]
Renaming is performed in atomic mode (atomically), which means that the table cannot be modified by any other thread when the renaming is running. This makes it possible to replace a table with an empty table.
Create Table new_table (...);
Rename table old_table to backup_table, new_table to old_table;
Rename is executed from left to right, which means that if you want to swap two table names, you have to do this:
Rename table old_table to backup_table,
New_table to old_table,
Backup_table to new_table;
As long as the two databases are on the same disk, you can change the name of one database to another:
Rename table current_db.tbl_name to other_db.tbl_name;
When you execute rename, you cannot have any locked table or activity transactions. You must also have the alter and drop permissions for the original table and the create and insert permissions for the new table.
If MySQL encounters any error in renaming multiple tables, it will rename all renamed tables and return everything to the initial state.
Rename table is added to MySQL 3.23.23.
Reprinted please note this article address: http://www.1366.me/xgjc/sjk_33_371.html