CREATE INDEX

To add an index definition to the store, use a CREATE INDEX statement. Its form is:

CREATE INDEX [IF NOT EXISTS] index-name ON table-name (field-name)

When indexing a map field, the previous syntax is acceptible, as are any of the following:

CREATE INDEX [IF NOT EXISTS] index-name ON table-name (KEYOF(field-name))

or

CREATE INDEX [IF NOT EXISTS] index-name ON table-name \
(ELEMENTOF(field-name))

or

CREATE INDEX [IF NOT EXISTS] index-name ON table-name \
(KEYOF(field-name),ELEMENTOF(field-name))

where:

For example, if table Users has a field called lastName, then you can index that field with the following statement:

CREATE INDEX surnameIndex ON Users (lastName)

Note that depending on the amount of data in your store, creating indexes can take a long time. This is because index creation requires Oracle NoSQL Database to examine all the data in the store.

For a description of using indexes with non-scalar data types, see Indexing Non-Scalar Data Types.