Skip to content

Rename a Table

Rename a Table

How to Rename a Table in SQL

Renaming tables helps to keep the database organized and readable. For example, when a database is refactored, it needs names reflecting the new structure or conventions.

You can use the ALTER TABLE statement with the RENAME TO clause to rename a table.

Here’s the syntax:

ALTER TABLE table_name RENAME TO new_table_name;

The ALTER TABLE command tells that you want to modify the structure of the table_name. For example, the RENAME TO clause specifies that you want to rename the table to new_table_name.

After running this statement, always use the new table name in future SQL queries. Note that any indexes, triggers, or other database objects associated with the table may need to be updated after the table is renamed.

An Easier Way to Rename a Table

If you are in Coginiti, you can right-click the table you want to rename. Then, the application will automatically generate the code with the proper schema, and you’ll only need to choose the new name for your table.

Screenshot of a dialog in Coginiti Pro showing how to use the automatically generate rename statement.