RENAME

Purpose

Use this statement to rename schemas and schema objects.

Prerequisites

  • If the object is a schema, you need the system privilege USE ANY SCHEMA or the object privilege USAGE on the schema, or the schema must be owned by you or one of your assigned roles.
  • If the object is a schema object, the object must be located in a schema that is owned by you or one of your assigned roles.
  • If the object is a user or role, you need the CREATE USER or CREATE ROLE privileges.
  • If the object is a consumer group, you need the system privilege MANAGE CONSUMER GROUPS.
  • If the object is a connection, at least one of the following prerequisites must be fulfilled:
    • You have the system privilege ALTER ANY CONNECTION
    • The connection is granted to you with the WITH ADMIN OPTION
    • The connection belongs to you or one of your assigned roles

Syntax

rename::=

Rename Object Statement

Usage notes

  • RENAME cannot be used to move a schema object to another schema. For example, RENAME TABLE s1.t1 TO s2.t2 is not allowed.
  • Distinguishing between schema and table is optional and only necessary if two identical objects share the same name.
  • In the system tables EXA_USER_VIEWS, EXA_ALL_VIEWS, and EXA_DBA_VIEWS, renaming a view only changes the VIEW_NAME and does not alter the VIEW_TEXT. This means that if VIEW_TEXT is used to recreate a view, the old/original name will be used.

  • In the system tables EXA_USER_FUNCTIONS, EXA_ALL_FUNCTIONS, and EXA_DBA_FUNCTIONS, renaming a function only changes the FUNCTION_NAME and does not alter the FUNCTION_TEXT. This means that if FUNCTION_TEXT is used to recreate a function, the old/original name will be used.

Examples

Copy
RENAME SCHEMA s1 TO s2;
RENAME TABLE t1 TO t2;
RENAME s2.t3 TO t4;