Syntax\n------\n\nRENAME TABLE[S] [IF EXISTS] tbl_name \n  [WAIT n | NOWAIT]\n  TO new_tbl_name\n    [, tbl_name2 TO new_tbl_name2] ...\n\nDescription\n-----------\n\nThis statement renames one or more tables or views, but not the privileges associated with them. For InnoDB tables, it also triggers a reload of InnoDB statistics.\n\nIF EXISTS\n\nIf this clause is used, you don't get an error if the table to be renamed doesn't exist.\n\nThe rename operation is done atomically, which means that no other session can access any of the tables while the rename is running. For example, if you have an existing table old_table, you can create another table new_table that has the same structure but is empty, and then replace the existing table with the empty one as follows (assuming that backup_table does not already exist):\n\n``sql\nCREATE TABLE new_table (...);\nRENAME TABLE old_table TO backup_table, new_table TO old_table;\n`\n\nMoving Tables to Another Database\n\ntbl_name can optionally be specified as db_name.tbl_name. See Identifier Qualifiers. This allows to use RENAME to move a table from a database to another (as long as they are on the same filesystem):\n\n`sql\nRENAME TABLE db1.t TO db2.t;\n`\n\nLimitations of Moving Tables to Another Database\n\nNote that moving a table to another database is not possible if it has triggers.\n\nTrying to do so produces the following error:\n\n`sql\nERROR 1435 (HY000): Trigger in wrong schema\n`\n\nViews cannot be moved to another database.\n\nTrying to do so produces the following error:\n\n`sql\nERROR 1450 (HY000): Changing schema from 'old_db' to 'new_db' is not allowed.\n`\n\nRenaming Multiple Tables at Once\n\nMultiple tables can be renamed in a single statement. The presence or absence of the optional S (RENAME TABLE or RENAME TABLES) has no impact, whether a single or multiple tables are being renamed.\n\nIf a RENAME TABLE renames more than one table and one renaming fails, all renames executed by the same statement are rolled back.\n\nRenames are always executed in the specified order. Knowing this, it is also possible to swap two tables' names:\n\n`sql\nRENAME TABLE t1 TO tmp_table,\n    t2 TO t1,\n    tmp_table TO t2;\n`\n\nWAIT/NOWAIT\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nPrivileges\n\nExecuting the RENAME TABLE statement requires the DROP, CREATE and INSERT privileges for the table or the database.\n\nAtomic RENAME TABLE\n\nRENAME TABLE is atomic for most storage engines, including InnoDB, MyRocks, MyISAM and Aria (MDEV-23842).\n\nThis means that if there is a crash (server down or power outage) during RENAME TABLE, all tables revert to their original names and any changes to trigger files are reverted.\\\n\\\nSee Atomic DDL for more information.\n\nRENAME TABLE is not atomic.\n\nThere is a small chance that, during a server crash happening in the middle of RENAME TABLE`, some tables could have been renamed (in the worst case partly) while others would not be renamed.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/rename-table