SQL RENAME

RENAME is a DDL (Data Definition Language) command used to change the name of a table or database object without affecting its data.

Renaming means changing the name of a table, column, or database object without affecting the data stored in it.
Important Notes:
1. Be careful when renaming columns because:
   • Stored procedures
   • Views
   • Applications
may depend on the old name.
2. Always test before renaming in production.

Syntax

RENAME TABLE old_table_name TO new_table_name;

Example

RENAME TABLE Orders TO CustomerOrders;

Now the table Orders is renamed to CustomerOrders.


Short Definition
. RENAME is a DDL command used to change the name of a database object such as a table.


Topics