RENAME
RENAME is a Data Definition Language (DDL) command in SQL used to change the name of a table or a column. This statement is used when a user intends to modify the existing name to a new specified name. It aids in enhancing readability and understanding of the schema structure for a user. This command varies across different SQL dialects.
Example
Output
Explanation
This code renames the “employees” table to “team”. The output “Query OK, 0 rows affected (0.02 sec)” signifies successful execution of the code.
Example
Output
Explanation
sp_rename
is a stored procedure that allows you to rename database objects like tables, columns, and indexes. The above command renames a table named old_table_name
to new_table_name
. Although SQL Server issues a warning, the rename operation still completes successfully.
Example
Output
This command does not provide any output. It performs the operation silently.
Explanation
In the given example, RENAME
is the SQL command used to change the name of old_table
to new_table
. If the operation is successful, Oracle doesn’t provide any output. If unsuccessful, Oracle will output an error message.