19.2 JSON_EXISTS as JSON_TABLE
SQL/JSON condition json_exists
can be viewed as a special case of SQL/JSON function json_table
.
Example 19-6 illustrates the equivalence: the two SELECT
statements have the same effect.
In addition to perhaps helping you understand json_exists
better, this equivalence is important practically, because it means that you can use either to get the same effect.
In particular, if you use json_exists
more than once, or you use it in combination with json_value
or json_query
(which can also be expressed using json_table
), to access the same data, then a single invocation of json_table
presents the advantage that the data is parsed only once.
Because of this, the optimizer often automatically rewrites multiple invocations of json_exists
, json_value
and json_query
(any combination) to fewer invocations of json_table
.
Note:
You can use SQL hint NO_JSON_TABLE_TRANSFORM
to prevent rewriting of
multiple invocations of json_exists
, json_value
and json_query
(any combination) to fewer invocations of
json_table
.
Example 19-6 JSON_EXISTS Expressed Using JSON_TABLE
SELECT select_list
FROM table WHERE json_exists(column,
json_path error_handler ON ERROR);
SELECT select_list
FROM table,
json_table(column, '$' error_handler ON ERROR
COLUMNS ("COLUMN_ALIAS" NUMBER EXISTS PATH json_path)) AS "JT"
WHERE jt.column_alias = 1;
Parent topic: SQL/JSON Condition JSON_EXISTS