SAND CDBMS SQL Reference Guide
RENAME TABLE

 

The RENAME TABLE command changes the name of an existing table or view.


Required Privileges

In order to rename a table or view, the user authorization must own the table/view, own or possess OWNER privileges on the schema to which the table/view belongs, or possess DBA privileges.


Syntax


old table name

This is the name of an existing table or view in the current schema. The table/view name may be qualified with a schema name (that is, schema-name.table-name or schema-name.view-name) to rename a table/view that is not in the current schema.

new table name
This is the new name for the table/view indicated by old table name. The new table/view name must not match the name of any other table or view in the specified schema, and cannot be qualified with a schema name since the new name applies to the table/view identified in old table name argument. It is strongly recommended that none of the SAND CDBMS SQL keywords be used as a new table name, as this may cause problems when referencing the table in certain SQL statements.

The keyword TO can optionally precede this argument.


Description

The RENAME TABLE statement changes the name of a specified table or view. The new table/view name can be up to 128 characters long and must be unique among all table or view names in the schema that contains the table. All other restrictions on database object names apply to the new table/view name (consult the section SAND CDBMS SQL Database Objects and Language Elements: Object Names for more information about database object names). Any table or column constraints that were defined, or privileges that were granted, previously on the old table/view name are maintained.


Example

RENAME TABLE state TO region;

The above example changes the name of the table state to region. Since the old table name is not prefixed with a schema name, SAND CDBMS will look in the current schema for the state table. Note that the TO keyword is optional; the command functions exactly the same way without it.