How to Rename a Table in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
This post covers how to rename a table in MySQL.
RENAME TABLE in MySQL?To rename a table in MySQL, you use the following simple SQL statement:
RENAME TABLE old_table_name TO new_table_name;
This command will change the name of old_table_name to new_table_name. Make sure the new table name does not clash with existing names in the database to avoid errors.
Let’s say you want to rename a table called user_data to customer_data. You would execute the following SQL statement:
RENAME TABLE user_data TO customer_data;
Executing this command requires updating all references to user_data in your application code, stored procedures, or scripts to customer_data.
MySQL lets you rename several tables in one operation. It’s cleaner and it reduces the risk of mistakes in large databases. Here’s how to do it:
RENAME TABLE old_table_name1 TO new_table_name1,
old_table_name2 TO new_table_name2;
Renaming multiple tables this way ensures the operation is atomic—all renames succeed together, or none at all, which should keeop your database consistent.
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.