CREATE INDEX

Description

Use the CREATE INDEX statement to create an index in the specified table.

Syntax

CREATE [ REVERSE ] [ UNIQUE ] INDEX [ index_name ]

ON table_name ( column_name[(prefix_length)] [ASC | DESC] [ {, column_name[(prefix_length)] [ASC | DESC]} ...] ) [ ; ]

Example 1

The following example shows how to create a reverse index.

CREATE REVERSE INDEX gold_index ON participant(gold);

Example 2

The following example shows how to create a multiple column index.

CREATE INDEX name_nation_idx ON athlete(name, nation_code);

Example 3

The following example shows how to create a single column index. In this example, 1-byte long prefix is specified for the nation_code column when creating an index.

CREATE INDEX ON game(nation_code(1));

CREATE INDEX game_date_idx ON game(game_date);