ALTER INDEX statement

Description

Renames indexes in base or global temporary tables and foreign key role names of indexes and foreign keys explicitly created by a user.

Syntax

Syntax 1

ALTER INDEX index-name rename-spec 

Syntax 2

ALTER [ INDEX ] FOREIGN KEY role-name rename-spec 

Parameters

rename-spec:

ON [ owner.]table-name RENAME [ AS | TO ] new-name

Examples

Example 1

Renames an index COL1_HG_OLD in the table jak.mytable to COL1_HG_NEW:

ALTER INDEX COL1_HG_OLD ON jak.mytable 
RENAME AS COL1_HG_NEW

Example 2

Renames a foreign key role name ky_dept_id in table dba.employee to emp_dept_id:

ALTER INDEX FOREIGN KEY ky_dept_id
ON dba.employee 
RENAME TO emp_dept_id

Usage

The ALTER INDEX statement renames indexes and foreign key role names of indexes and foreign keys that were explicitly created by a user. Only indexes on base tables or global temporary tables can be renamed. You cannot rename indexes created to enforce key constraints.

ON claus The ON clause specifies the name of the table that contains the index or foreign key to rename.

RENAME [ AS | TO ] claus The RENAME clause specifies the new name of the index or foreign key role.

NoteAttempts to alter an index in a local temporary table return the error “index not found.” Attempts to alter a nonuser-created index, such as a default index (FP), return the error “Cannot alter index. Only indexes in base tables or global temporary tables with an owner type of USER can be altered.”


Side Effects

Automatic commit. Clears the Results tab in the Results pane in Interactive SQL. Closes all cursors for the current connection.

Standards

Permissions

Must own the table, or have REFERENCES permissions on the table, or have DBA authority.

See also

ALTER TABLE statement

CREATE INDEX statement

CREATE TABLE statement