CREATE INDEX v10
CREATE INDEX -- define a new index.
CREATE INDEX constructs an index,
name, on the specified table. Indexes are primarily used to enhance database performance (though inappropriate use will result in slower performance).
Note: An index cannot be created on a partitioned table.
The key field(s) for the index are specified as column names, or alternatively as expressions written in parentheses. Multiple fields can be specified to create multicolumn indexes.
An index field can be an expression computed from the values of one or more columns of the table row. This feature can be used to obtain fast access to data based on some transformation of the basic data. For example, an index computed on
UPPER(col) would allow the clause
WHERE UPPER(col) = 'JIM' to use an index.
Advanced Server provides the B-tree index method. The B-tree index method is an implementation of Lehman-Yao high-concurrency B-trees.
Indexes are not used for
IS NULL clauses by default.
All functions and operators used in an index definition must be "immutable", that is, their results must depend only on their arguments and never on any outside influence (such as the contents of another table or the current time). This restriction ensures that the behavior of the index is well-defined. To use a user-defined function in an index expression remember to mark the function immutable when you create it.
Causes the system to check for duplicate values in the table when the index is created (if data already exist) and each time data is added. Attempts to insert or update data which would result in duplicate entries will generate an error.
The name of the index to be created. No schema name can be included here; the index is always created in the same schema as its parent table.
The name (possibly schema-qualified) of the table to be indexed.
The name of a column in the table.
An expression based on one or more columns of the table. The expression usually must be written with surrounding parentheses, as shown in the syntax. However, the parentheses may be omitted if the expression has the form of a function call.
The tablespace in which to create the index. If not specified,
default_tablespace is used, or the database’s default tablespace if
default_tablespace is an empty string.
Up to 32 fields may be specified in a multicolumn index.
To create a B-tree index on the column,
ename, in the table,
To create the same index as above, but have it reside in the