Renaming a table
suggest changeRenaming a table can be done in a single command:
RENAME TABLE `<old name>` TO `<new name>`;
The following syntax does exactly the same:
ALTER TABLE `<old name>` RENAME TO `<new name>`;
If renaming a temporary table, the ALTER TABLE
version of the syntax must be used.
Steps:
- Replace
<old name>
and<new name>
in the line above with the relevant values. Note: If the table is being moved to a different database, thedbname
.tablename
syntax can be used for<old name>
and/or<new name>
. - Execute it on the relevant database in the MySQL command line or a client such as MySQL Workbench. Note: The user must have ALTER and DROP privileges on the old table and CREATE and INSERT on the new one.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents