Home »
MySQL
MySQL RENAME TABLE Statement
MySQL | RENAME TABLE: Learn about the MySQL RENAME TABLE statement, with its explanation, syntax, and query examples.
Submitted by Apurva Mathur, on September 05, 2022
RENAME TABLE Statement
Most of the time when we start any project we usually keep the temporary name, but as soon as we go along with the project we get the appropriate names for the tables, in this case, RENAME TABLE statement helps us to change the name of the tables.
RENAME TABLE Statement Syntax
ALTER TABLE table_name
RENAME TO new_table_name;
RENAME TABLE in MYSQL Command-Line Client
Suppose I have a database named "new_schooldb" and inside that database, we have the following tables,
And now, if I want to rename the database named "student_details" to details, we will write the following query;
ALTER TABLE student_details RENAME to details;
This is the case when we are renaming a single table at a time, what if we want to rename more than one table in one query, in such situation we will use the following query;
RENAME TABLE student_subjects TO subjects, student_attendance TO attendance;
As you can see my table named "student_attendance" and "student_subjects" is now changed to attendance and subjects respectively.