SQL - Rename Table

To rename a table in SQL, you can use the ALTER TABLE statement along with the RENAME TO clause. The RENAME TO clause allows you to change the name of an existing table.

ALTER TABLE current_table_name RENAME TO new_table_name;
  • ALTER TABLE: This SQL keyword is used to indicate that you want to modify the structure of a table.
  • current_table_name: Specify the current name of the table you want to rename.
  • RENAME TO: This clause is used to indicate that you want to rename the table.
  • new_table_name: Specify the new name you want to assign to the table.

For example, to rename a table named "Employees" to "Staff", you would use the following statement:

ALTER TABLE Employees RENAME TO Staff;

Executing this statement will change the name of the table from "Employees" to "Staff". The table will retain its structure and data, but it will be accessible using the new name.

It's important to note that renaming a table can have implications on other database objects, such as views, stored procedures, or queries, that reference the table by its original name. You may need to update those references accordingly.

Additionally, some database management systems may have specific rules or restrictions on table renaming. For example, you may need appropriate privileges or permissions to perform the renaming operation. Refer to the documentation of your specific database management system for more information on table renaming and its usage.