background image
<< LOCK TABLE statement | REVOKE statement >>

RENAME statements

<< LOCK TABLE statement | REVOKE statement >>
Derby Reference Manual
63
LOCK TABLE Maps IN EXCLUSIVE MODE;
SELECT MAX(map_id) + 1 FROM Maps;
-- INSERT INTO Maps . . .
RENAME statements
Use the Rename statements with indexes, columns, and tables.
RENAME COLUMN statement
Use the RENAME COLUMN statement to rename a column in a table.
The RENAME COLUMN statement allows you to rename an existing column in an
existing table in any schema (except the schema SYS).
To rename a column, you must either be the database owner or the table owner.
Other types of table alterations are possible; see
ALTER TABLE statement
for more
information.
Syntax
RENAME COLUMN
table-Name
.
simple-Column-Name
TO
simple-Column-Name
Examples
To rename the manager column in table employee to supervisor, use the following
syntax:
RENAME COLUMN EMPLOYEE.MANAGER TO SUPERVISOR
You can combine ALTER TABLE and RENAME COLUMN to modify a column's data
type. To change column c1 of table t to the new data type NEWTYPE:
ALTER TABLE t ADD COLUMN c1_newtype NEWTYPE
UPDATE t SET c1_newtype = c1
ALTER TABLE t DROP COLUMN c1
RENAME COLUMN t.c1_newtype TO c1
Usage notes
Restriction:
If a view, trigger, check constraint, foreign key constraint, or
generation-clause of a generated column references the column, an attempt to rename it
will generate an error.
Restriction: The RENAME COLUMN statement is not allowed if there are any open
cursors that reference the column that is being altered.
Note: If there is an index defined on the column, the column can still be renamed; the
index is automatically updated to refer to the column by its new name
RENAME INDEX statement
This statement allows you to rename an index in the current schema. Users cannot
rename indexes in the SYS schema.
Syntax
RENAME INDEX index-Name TO new-index-Name
Example
RENAME INDEX DESTINDEX TO ARRIVALINDEX
Statement dependency system
RENAME INDEX is not allowed if there are any open cursors that reference the index
being renamed.