CREATE INDEX statement 

The CREATE INDEX statement creates an index of a base table (see table).

Syntax

<create_index_statement> ::=
  CREATE [UNIQUE] INDEX <table_name>.<column_name> [ASC | DESC]
| CREATE [UNIQUE] INDEX <index_name> ON <table_name> (<column_name> [ASC | DESC],...)

table_name, column_name, index_name

Explanation

The index is created across the specified table columns. The secondary key consists of the specified columns of the table, in the specified order.

The specified table must be an existing base table, and not a temporary table.

If an index was created across exactly one column, a further one-column index cannot be created for this column.

The column defined by the column_name must be a column in the specified table. This column must not be a LONG column. All of the column name pairs must be different.

The current user must have the INDEX privilege for the columns.

The sum of the internal lengths of the identified columns must not exceed 1024 characters.

Indexes provide access to the table data via non-key columns. Maintaining these indexes, however, can be quite complex in the case of the INSERT, UPDATE, and DELETE statements.

CREATE [UNIQUE] INDEX <index_name> ON <table_name> (<column_name> [ASC | DESC],...)

If you use this statement, you must make sure that you do not use more than 16 column names. The index name must not be identical with an existing index name of the table. A maximum of 255 indexes can be created for each table using this statement.

If the only difference between the defined index and an index that already exists for the table is the index name, the create index statement will fail.

UNIQUE

If UNIQUE is specified, the database system ensures that no two rows of the specified table have the same values in the indexed columns. NULL values in one-column indexes are considered to be non-identical.

ASC | DESC

The index values are stored in ascending or descending order. If the specification of ASC or DESC is omitted, ASC is implicitly assumed.