OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.1

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.1
    iconOceanBase Database
    SQL - V 4.3.1
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    JSON_EXISTS

    Last Updated:2026-04-15 08:25:15  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples

    folded

    share

    Purpose

    JSON_EXISTS() works as an SQL condition in an SQL statement to check whether the JSON data in a specified path exists or meets specific conditions. This function can be understood as a filter condition for JSON data. If the JSON data exists, this function returns TRUE. If the JSON data does not exist, this function returns FALSE.

    Syntax

    JSON_EXISTS(
                  expr [FORMAT JSON],
                  json_path_literal
                     [PASSING expr AS identifier]
                     [ERROR|TRUE|FALSE ON ERROR]
                  [ERROR|TRUE|FALSE ON EMPTY]);
    
    

    Parameters

    The parameters in the syntax are described as follows:

    • FORMAT JSON: This clause is optional. It is required when the data type of expr is BLOB.
    • json_path_literal: specifies the query path. This parameter is required. You can use a json_path statement with a filter condition.
    • ERROR:
      • ERROR ON ERROR: specifies to return an error when the value of expr is not valid JSON data.
      • TRUE ON ERROR: specifies to return TRUE when the value of expr is not valid JSON data.
      • FALSE ON ERROR: specifies to return FALSE when the value of expr is not valid JSON data. This is the default setting.
    • EMPTY: specifies to return FALSE when no TRUE result exists.
    • PASSING: specifies to pass external SQL variables to the json_path parameter for comparing the values in the path specified in the filter expression with the SQL variables.

    Examples

    # Use default arguments to select JSON values meeting the conditions.
    CREATE TABLE t (name VARCHAR2(100));
    INSERT INTO t VALUES ('[{first:"John"}, {middle:"Mark"}, {last:"Smith"}]');
    INSERT INTO t VALUES ('[{first:"Mary"}, {last:"Jones"}]');
    INSERT INTO t VALUES ('[{first:"Jeff"}, {last:"Williams"}]');
    INSERT INTO t VALUES ('[{first:"Jean"}, {middle:"Anne"}, {last:"Brown"}]');
    INSERT INTO t VALUES (NULL);
    INSERT INTO t VALUES ('This is not well-formed JSON data');
    
    obclient> SELECT name FROM t  WHERE JSON_EXISTS(name, '$[0].first');
    +---------------------------------------------------+
    | NAME                                              |
    +---------------------------------------------------+
    | [{first:"John"}, {middle:"Mark"}, {last:"Smith"}] |
    | [{first:"Mary"}, {last:"Jones"}]                  |
    | [{first:"Jeff"}, {last:"Williams"}]               |
    | [{first:"Jean"}, {middle:"Anne"}, {last:"Brown"}] |
    +---------------------------------------------------+
    4 rows in set
    
    # Set the JSON_EXIST clause to return FALSE when no matching item is found or the value of expr is not valid JSON data.
    obclient> SELECT name FROM t WHERE JSON_EXISTS(name, '$[1].middle');
    +---------------------------------------------------+
    | NAME                                              |
    +---------------------------------------------------+
    | [{first:"John"}, {middle:"Mark"}, {last:"Smith"}] |
    | [{first:"Jean"}, {middle:"Anne"}, {last:"Brown"}] |
    +---------------------------------------------------+
    2 rows in set
    
    # Set the PASSING clause to pass variables to the json-path parameter.
    obclient> SELECT name FROM t WHERE JSON_EXISTS(name, '$[1]?(@.middle == $var1)' PASSING 'Anne' as "var1");
    +---------------------------------------------------+
    | NAME                                              |
    +---------------------------------------------------+
    | [{first:"Jean"}, {middle:"Anne"}, {last:"Brown"}] |
    +---------------------------------------------------+
    1 row in set
    

    Previous topic

    JSON_QUERY
    Last

    Next topic

    JSON_TABLE
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples