How to Change a Table Name in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Changing a table name in MySQL is pretty simple. You can do it with the RENAME TABLE statement. This post explores how it works.
RENAME TABLE in MySQL?Use the RENAME TABLE statement to change the name of an existing table to a new one. Here’s the basic syntax for executing this operation in MySQL:
RENAME TABLE old_table_name TO new_table_name;
To rename a table from user_data to customer_data, execute the following SQL command:
RENAME TABLE user_data TO customer_data;
By running this command, you will have successfully renamed the user_data table to customer_data.
MySQL facilitates renaming multiple tables in a single operation, which is particularly handy for applying batch updates to your database schema. The syntax to rename multiple tables at once is as follows:
RENAME TABLE old_table_name1 TO new_table_name1,
old_table_name2 TO new_table_name2,
...;
For instance, to rename table1 to new_table1 and table2 to new_table2, use:
RENAME TABLE table1 TO new_table1,
table2 TO new_table2;
Understanding and utilizing the ability to rename tables in MySQL is crucial for maintaining an organized and efficient database schema, highlighting the value of good naming practices in database administration.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.