Blog Bustle 08/03/2020
Sql rename table query is used to change table name in database. We can rename one or more tables using single query.
There are two methods to change table name in database. You can use any of them. Both are correct.
RENAME TABLE table_name to new_table_name;
table1_name to new_table1_name,
table2_name to new_table2_name,
table3_name to new_table3_name,
tableN_name to new_tableN_name;
ALTER TABLE table_name RENAME TO new_table_name;
For example, i have two tables class and subject in student database.
i will change class table name to classes using rename table and sql rename table query will be
rename table class to classes;
now i will change subject table name to subjects using alter table and sql rename table query will be
alter table subject
rename to subjects;
Remember that first select database then run any sql query related to that database otherwise you will get 'no database selected' error.
So we can easily change table name in database using sql rename table query. Hope you like this tutorial.