CREATE INDEX Statement

Create a new index on the specified columns in an SQL table.

Syntax

CREATE {UNIQUE} INDEX index-name ON base-table-name (column-identifier {[ASC || DESC]}{, column-identifier)

Syntax Elements

index-name =
{index-qualifier.}index-identifier

index-qualifier
This must be the same as base-table-name.

index-identifier
Any user-defined name (except a Reserved Word) starting with a letter and comprising up to 49 letters, underscores and/or numbers. Letters are case sensitive.

base-table-name =
{owner-name.}base-table-identifier

owner-name
The SQL user-id of the creator of the table.

base-table-identifier
The name of the table to index.

column-identifier
The name of the column to be indexed.

Restrictions

Comments

See Recommendations for Creating Indexes.

This statement creates a regular Reality index that can also be used by other Reality processes such as English.

An index created with the CREATE INDEX statement will be deleted by a DROP TABLE statement on that table.

If the UNIQUE option is used, the indexed column(s) will be constrained to contain no more than one occurrence of each value (including null).

The index can be created in ascending (ASC) or descending (DESC) ASCII order. Ascending order is the default, if neither ASC nor DESC is specified.

Where exploded multi- or sub-values exist, one index entry is created per multi- or sub-value. (Exploding multi- or sub-values places them in separate table rows. They are specified as exploding via fields 6 or 7 of the SQL column definition. For more information about column definition, see SQL Column and Index Definitions.

Examples

CREATE INDEX DEPTIDX ON EMP(DEPTNO)
CREATE UNIQUE INDEX RB2 ON EMP(DEPTNO ASC, EMPNO DESC)

Go to top button