Index Creation Syntax

Create JSON indexes with concise dot notation or explicit function-based expressions.

Dot-notation syntax is presented first, followed by standard function-based syntax. Both forms work, but dot notation is preferred because it is more concise and aligns with JSON path usage in queries.

Dot-Notation Syntax

Use dot notation to define JSON indexes without writing explicit json_value or json_exists expressions. Specify the indexed fields directly using dot paths, and Oracle creates the underlying index definition.

CREATE JSON [UNIQUE] [SPARSE | DENSE] [SINGLEVALUE | MULTIVALUE]
INDEX index_name ON table_name [table_alias]
(dot_path [ASC | DESC], [dot_path [ASC | DESC]] ...)
[index_properties];

Parameters and Options

Parameter Description
JSON Mandatory keyword that triggers use of the simplified JSON index syntax.
UNIQUE Optional parameter that enforces uniqueness across the specified indexed fields.
SPARSE / DENSE Optional parameter. SPARSE uses a NULL ON EMPTY handler. DENSE uses a PRESENT ON EMPTY handler. If neither keyword is specified, SPARSE is the default.
SINGLEVALUE / MULTIVALUE Optional parameter. SINGLEVALUE creates an index for scalar fields. MULTIVALUE creates an index for arrays or repeated values and is the default.
INDEX index_name Required parameter that specifies the name of the index to create.
ON table_name [table_alias] Required parameter that identifies the table and optional alias containing the JSON column to index.
dot_path [ASC | DESC] One or more dot-separated paths that specify the fields to index. You can specify ascending or descending order for each field.
index_properties Optional parameter that specifies additional index properties, such as ONLINE for online creation.

Consider the following restrictions:

Standard Function-Based Syntax

Use the standard syntax when you need explicit json_value behavior, such as RETURNING, ERROR ON ERROR, or NULL ON EMPTY. Use it also when you need to index NULL values using a constant column. This form is required for bitmap indexes.

CREATE [UNIQUE] INDEX index_name ON table_name [table_alias]
  (json_value(json_column, 'path' [RETURNING sql_type]
     [ERROR ON ERROR | NULL ON ERROR]
     [NULL ON EMPTY | ERROR ON EMPTY]));

For a multivalue index for json_exists, use this syntax:

CREATE [UNIQUE] MULTIVALUE INDEX index_name ON table_name [table_alias]
  (json_column.path_expression.item_method());

Standard Syntax Parameters

Parameter Description
UNIQUE Enforces uniqueness across the indexed fields.
index_name Name of the index.
table_name [table_alias] Table and optional alias containing the JSON column.
json_value(...) Function-based expression that returns a single scalar value.
RETURNING sql_type Specifies the SQL return type for json_value.
ERROR ON ERROR / NULL ON ERROR Error-handling behavior for type or structural mismatches.
NULL ON EMPTY / ERROR ON EMPTY Handling for missing fields.
MULTIVALUE Creates a multivalue function-based index for json_exists predicates.
item_method() Data-type conversion method, such as string() or number(), that sets the SQL type for non-composite multivalue indexes.

Note: Standard syntax is fully supported, but dot notation is preferred for most JSON indexing because it is simpler and more readable.