MySQL - RENAME TABLE
RENAME TABLE customer to customer2;
RENAME TABLE backup_customer TO customer, backup_vendor TO vendor, backup_products TO product;

RENAME TABLE has an advantage over ALTER TABLE in that it can perform multiple table renames in a single operation. One use for this feature is to swap the names of two tables:

RENAME TABLE t1 TO tmp, t2 TO t1, tmp to t2;

For TEMPORARY tables, RENAME TABLE does not work. You must use ALTER TABLE instead.

To swap tables:

RENAME TABLE
db.table1 to olddb.table1, /* back up the current table */
newdb.table1 to db.table1 /* rename the new table as the old one */
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License