RENAME
Example
Section titled “Example”ALTER TABLE employeesRENAME TO team;Output
Section titled “Output”Query OK, 0 rows affected (0.02 sec)Explanation
Section titled “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
Section titled “Example”EXEC sp_rename 'old_table_name', 'new_table_name'Output
Section titled “Output”Caution: Changing any part of an object name could break scripts and stored procedures.Explanation
Section titled “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
Section titled “Example”RENAME TABLE old_table TO new_table;Output
Section titled “Output”This command does not provide any output. It performs the operation silently.
Explanation
Section titled “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.