In an embedded Create Index statement, the following elements can be replaced with host language variables:
Elements |
Description |
---|---|
location_name |
Specifies the location of the index; must be a string variable. |
N |
Specifies fill and page values; must be an integer variable. |
The preprocessor does not validate the with clause syntax. The with clause can be specified using a host string variable (with :hostvar).
You must be the owner of a table. Users cannot update indexes directly. When a table is changed, the DBMS Server updates indexes as required. To create indexes on system tables, the effective user of the session must be $ingres. For information about the $ingres user, see the System Administrator Guide.
Creating an index on a table requires an exclusive lock on the table. This lock prevents other sessions, even those using the readlock=nolock option, from accessing the table until create index completes and the transaction containing it is completed.
The following are Create Index statement examples:
create index ename on employee (ename, age)
with persistence;
create index ename on employee (ename, age)
with location = (remote);
create index ename2 on employee (ename, eage)
with key = (ename),
structure = btree,
leaffill = 50;
create unique index ename3 on employee (ename, empno)
with key = (ename, empno),
unique_scope = statement;
create index i1 on t1 (c1) unique
create unique index (i1 on t1(c1) with structure=hash)
create unique index (i1 on t1(c1) with structure=hash,persistence),
(i2 on t1(c2) with structure=btree)
create index (i1 on t1 (c1) unique with structure=hash,persistence), (i2 on
t1(c2) unique with structure=btree)
create index (i1 on t1(c1) unique with structure=hash,persistence),
(i2 on t1(c2) with structure=btree)
Note: Examples 7 and 8 perform the same operation, while 9 demonstrates individual control of the UNIQUE attribute.