TurboSQL Guide

CREATE INDEX Statement

Previous  Top  Next


Creates a new index for an existing table.

Syntax

CREATE [UNIQUE] INDEX index_reference ON table_reference (column_reference [ASC|DESC] [,column_reference [ASC|DESC] ...] )

Description

Indexes are used to speed up query execution. Use the CREATE INDEX command to add a new index to an existing table:

CREATE INDEX OrderIdIdx ON Orders (OrderId ASC)

You may create multi-level hierarchical indexes as well:

CREATE INDEX TargetDateIdx ON Orders (DeliveryDate DESC, OrderId)

Use UNIQUE to create an index that raises an error if rows with duplicate column values are inserted. By default, indexes are not unique.

Note

The ASC and DESC attribute at column level is a proprietary extension to SQL-92.