Tutorialsteacher

Follow Us

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.

SQL Script: Rename Table in MySQL, PostgreSQL, and SQLite
ALTER TABLE Employee RENAME TO Emp;

The following statement will rename Employee table to TempEmployee in the Oracle database.

SQL Script: Rename Table in Oracle
RENAME Employee TO TempEmployee;

Use the sp_rename built-in stored procedure to rename a table in the SQL Server database.

SQL Script: Rename Table in SQL Server
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.