Swap two MySQL table names

Make sure that a table with the intermediary name tmp_table does not already exist:


RENAME TABLE old_table TO tmp_table,
             new_table TO old_table,
             tmp_table TO new_table;

Comments