CREATE INDEX Statement

Creates an index on a specified table, or pair of tables. Once an index is created, it is never referenced in an SQL statement again except to delete it using the DROP INDEX statement.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

CREATEUNIQUE ] [ index-type ] INDEX [ IF NOT EXISTS ] index-nameONowner.]table-name
   … ( column-name [ , column-name ] …)
   …[ { IN | ON } dbspace-name ]
   …[ NOTIFY integer ]
   …[ DELIMITED BY 'separators-string‘ ]
   …[ LIMIT maxwordsize-integer ]

index-typeCMP | HG | HNG | LF | WD | DATE | TIME | DTTM }

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

Warning!   Using the CREATE INDEX command on a local temporary table containing uncommitted data fails and generates the error message Local temporary table, <tablename>, must be committed in order to create an index. Commit the data in the local temporary table before creating an index.
Side Effects
  • Automatic commit

Standards

(back to top)

  • SQL—Vendor extension to ISO/ANSI SQL grammar.
  • SAP Sybase Database product—Adaptive Server has a more complex CREATE INDEX statement than SAP Sybase IQ. While the Adaptive Server syntax is permitted in SAP Sybase IQ, some clauses and keywords are ignored. For the full syntax of the Adaptive Server CREATE INDEX statement, see the Adaptive Server Reference Manual, Volume 2: Commands.

Adaptive Server indexes can be either clustered or nonclustered. A clustered index almost always retrieves data faster than a nonclustered index. Only one clustered index is permitted per table.

SAP Sybase IQ does not support clustered indexes. The CLUSTERED and NONCLUSTERED keywords are allowed by SQL Anywhere, but are ignored by SAP Sybase IQ. If no index-type is specified, SAP Sybase IQ creates an HG index on the specified column(s).

SAP Sybase IQ does not permit the DESC keyword.

Index names must be unique on a given table for both SAP Sybase IQ and Adaptive Server.

Permissions

(back to top)

Requires CREATE privilege on the dbspace where the index is being created. Also requires one of::
Related reference
BEGIN PARALLEL IQ … END PARALLEL IQ Statement
DROP Statement
INDEX_PREFERENCE Option
FROM Clause