602SQL Documentation Index  

RENAME Statement

statement_RENAME ::= RENAME category [schema.]object_name TO new_object_name
category ::= TABLE | VIEW | DOMAIN | SEQUENCE | TRIGGER | PROCEDURE | FUNCTION | SCHEMA | USER | GROUP | ROLE

The RENAME statement renames an object specified by the object_name in the specified schema of the specified category to the new_object_name. Schema is not specified for USER, GROUP and SCHEMA categories. For all other categories, if the schema is not specified, objects in the active schema are used.

If the object of the specified name already exists, the error sqlstate 40004 (KEY_DUPLICITY) occurs. If the user doesn't have sufficient privileges to rename the object or a related object (e.g. a trigger) the W0129 (NO_RIGHT) sqlstate occurs.

You must change the old object name to the new one everywhere it is used to ensure application functionality. This task is done partially by the 602SQL Server and partially by the application author. Details can be found here.

Table renaming is done in a single transaction. The transaction is terminated once it is done.

Example

Change the table name from Test to Table_abc in the current application.

RENAME TABLE Test TO Table_abc

See