---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://ydb-platform--ydb.viewer.diplodoc.com/en/yql/reference/syntax/create_table/json_index.md
  - https://ydb-platform--ydb.viewer.diplodoc.com/ru/yql/reference/syntax/create_table/json_index.md
  - href: https://ydb-platform--ydb.viewer.diplodoc.com/en/yql/reference/syntax/create_table/json_index.md
    type: text/markdown
    title: Markdown version
  - href: https://ydb-platform--ydb.viewer.diplodoc.com/en/llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/yql/reference/syntax/create_table/json_index.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb-platform--ydb.viewer.diplodoc.com/en/llms.txt

# JSON-index

 [JSON indexes](https://ydb-platform--ydb.viewer.diplodoc.com/en/dev/json-indexes.md) in [row](https://ydb-platform--ydb.viewer.diplodoc.com/en/concepts/datamodel/table.md#row-oriented-tables) tables are created using the same syntax as [secondary indexes](https://ydb-platform--ydb.viewer.diplodoc.com/en/yql/reference/syntax/create_table/secondary_index.md), by specifying `json` as the index type. A subset of the syntax available for JSON indexes:


```yql
CREATE TABLE `<table_name>` (
    ...
    INDEX `<index_name>`
        GLOBAL
        [SYNC]
        USING json
        ON ( <json_column> )
    [,   ...]
)
```


Where:

* `<index_name>` — unique index name for data access.
* `SYNC` — specifies synchronous index update. This is the only mode available for JSON indexes; explicit specification is not required.
* `<json_column>` — table column of type `Json` or `JsonDocument`. A JSON index is built on a single column only.

A JSON index does not support the `COVER` expression — attempting to specify it will result in an error.

<!-- source: en/_includes/not_allow_for_olap_note.md -->
{% note warning %}

<!-- source: en/_includes/not_allow_for_olap_text.md -->
Supported only for [row-oriented](https://ydb-platform--ydb.viewer.diplodoc.com/en/concepts/datamodel/table.md#row-oriented-tables) tables. Support for [column-oriented](https://ydb-platform--ydb.viewer.diplodoc.com/en/concepts/datamodel/table.md#column-oriented-tables) tables is currently under development.
<!-- endsource: en/_includes/not_allow_for_olap_text.md -->

{% endnote %}
<!-- endsource: en/_includes/not_allow_for_olap_note.md -->

## Example


```yql
CREATE TABLE documents (
    id Uint64 NOT NULL,
    payload JsonDocument NOT NULL,
    INDEX json_idx GLOBAL USING json ON (payload),
    PRIMARY KEY (id)
)
```


In this example, a table `documents` is created with a JSON index `json_idx` on column `payload`. The index will be used by queries whose `WHERE` predicate contains calls to `JSON_EXISTS` or `JSON_VALUE` on column `payload`.
