SQL - Rename Tables in the Database
Different databases support the different syntax to rename a table.
Use the following ALTER TABLE RENAME script to rename table names in the MySQL, PostgreSQL, and SQLite database.
ALTER TABLE Employee RENAME TO Emp;
The following statement will rename Employee
table to TempEmployee
in the Oracle database.
RENAME Employee TO TempEmployee;
Use the sp_rename
built-in stored procedure to rename a table in the SQL Server database.
sp_rename Employee, emp;
Make sure that the original table name is correct, and the new name has not been used with other database objects; otherwise, it will raise an error.