drop table PLAN_TABLE
create table PLAN_TABLE (
statement_id varchar2(30),
plan_id number,
timestamp date,
remarks varchar2(4000),
operation varchar2(30),
options varchar2(255),
object_node varchar2(128),
object_owner varchar2(30),
object_name varchar2(30),
object_alias varchar2(65),
object_instance numeric,
object_type varchar2(30),
optimizer varchar2(255),
search_columns number,
id numeric,
parent_id numeric,
depth numeric,
position numeric,
cost numeric,
cardinality numeric,
bytes numeric,
other_tag varchar2(255),
partition_start varchar2(255),
partition_stop varchar2(255),
partition_id numeric,
other long,
distribution varchar2(30),
cpu_cost numeric,
io_cost numeric,
temp_space numeric,
access_predicates varchar2(4000),
filter_predicates varchar2(4000),
projection varchar2(4000),
time numeric,
qblock_name varchar2(30),
other_xml clob
)
drop table t
create table t (jcol varchar(32767) check (jcol is json))
insert into t values ('{"a":1, "b":2}')
insert into t values ('{"a":2, "b":[3,4]}')
insert into t values ('{"a":3, "b":5}')
commit
select t.jcol, t.jcol.a from t t
select t.jcol, t.jcol.b from t t
select JSON_VALUE(jcol, '$.a' RETURNING NUMBER) from T
select jcol from t where JSON_VALUE(jcol, '$.a' RETURNING NUMBER) > 2
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_VALUE(jcol, '$.a' RETURNING NUMBER) > 2
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
create index idx1 on t (JSON_VALUE(jcol, '$.a' RETURNING NUMBER))
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_VALUE(jcol, '$.a' RETURNING NUMBER) > 2
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
select jcol from t where JSON_EXISTS(jcol, '$?(@.a > 2)' )
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_EXISTS(jcol, '$?(@.a > 2)' )
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
drop index idx1
create index idx1 on t (JSON_VALUE(jcol, '$.a' RETURNING NUMBER ERROR ON ERROR NULL ON EMPTY))
select jcol from t where JSON_EXISTS(jcol, '$?(@.a > 2)' )
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_EXISTS(jcol, '$?(@.a > 2)' )
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
insert into t values('{a:[8,9]}');
select t.jcol, t.jcol.b from t t
drop index idx1
create index idx1 on t (JSON_VALUE(jcol, '$.b' RETURNING NUMBER ERROR ON ERROR NULL ON EMPTY))
create index idx1 on t (JSON_VALUE(jcol, '$.b' RETURNING NUMBER DEFAULT '0' ON ERROR NULL ON EMPTY))
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_VALUE(jcol, '$.b' RETURNING NUMBER DEFAULT '-1' ON ERROR NULL ON EMPTY) > 2
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
select jcol from t where JSON_VALUE(jcol, '$.b' RETURNING NUMBER DEFAULT '0' ON ERROR NULL ON EMPTY) = 0
create search index j_search_idx on t (jcol) for json
drop index idx1
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_VALUE(jcol, '$.b' RETURNING NUMBER) > 2
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'
delete from plan_table
EXPLAIN PLAN
SET STATEMENT_ID = 'jsonPlan'
FOR
select jcol from t where JSON_EXISTS(jcol, '$?(@.b > 2)' )
SELECT LPAD('............................',2*(LEVEL-1))||operation operation, options,
object_name, position
FROM plan_table
START WITH id = 0 AND statement_id = 'jsonPlan'
CONNECT BY PRIOR id = parent_id AND statement_id = 'jsonPlan'