SET LONG 1000000 PAGESIZE 1000
SELECT DBMS_JSON.get_index_dataguide(
'json_documents',
'data',
DBMS_JSON.format_flat,
DBMS_JSON.pretty) AS dg
FROM dual;
DG
--------------------------------------------------------------------------------
[
{
"o:path" : "$.Job",
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DG_JOB"
},
{
"o:path" : "$.Active",
"type" : "boolean",
"o:length" : 8,
"o:preferred_column_name" : "DG_ACTIVE"
},
{
"o:path" : "$.Address",
"type" : "object",
"o:length" : 128,
"o:preferred_column_name" : "DATA$Address"
},
{
"o:path" : "$.Address.City",
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$City"
},
{
"o:path" : "$.Address.Street",
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$Street"
},
{
"o:path" : "$.Address.Country",
"type" : "string",
"o:length" : 2,
"o:preferred_column_name" : "DATA$Country"
},
{
"o:path" : "$.Address.Postcode",
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DG_POSTCODE"
},
{
"o:path" : "$.LastName",
"type" : "string",
"o:length" : 4,
"o:preferred_column_name" : "DATA$LastName"
},
{
"o:path" : "$.FirstName",
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$FirstName"
},
{
"o:path" : "$.DateOfBirth",
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$DateOfBirth"
},
{
"o:path" : "$.ContactDetails",
"type" : "object",
"o:length" : 128,
"o:preferred_column_name" : "DATA$ContactDetails"
},
{
"o:path" : "$.ContactDetails.Email",
"type" : "string",
"o:length" : 32,
"o:preferred_column_name" : "DATA$Email"
},
{
"o:path" : "$.ContactDetails.Phone",
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$Phone"
},
{
"o:path" : "$.ContactDetails.Twitter",
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$Twitter"
}
]
SQL>
SET LONG 1000000 PAGESIZE 1000
SELECT DBMS_JSON.get_index_dataguide(
'json_documents',
'data',
DBMS_JSON.format_hierarchical,
DBMS_JSON.pretty) AS dg
FROM dual;
DG
--------------------------------------------------------------------------------
{
"type" : "object",
"properties" :
{
"Job" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DG_JOB"
},
"Active" :
{
"type" : "boolean",
"o:length" : 8,
"o:preferred_column_name" : "DG_ACTIVE"
},
"Address" :
{
"type" : "object",
"o:length" : 128,
"o:preferred_column_name" : "DATA$Address",
"properties" :
{
"City" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$City"
},
"Street" :
{
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$Street"
},
"Country" :
{
"type" : "string",
"o:length" : 2,
"o:preferred_column_name" : "DATA$Country"
},
"Postcode" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DG_POSTCODE"
}
}
},
"LastName" :
{
"type" : "string",
"o:length" : 4,
"o:preferred_column_name" : "DATA$LastName"
},
"FirstName" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$FirstName"
},
"DateOfBirth" :
{
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$DateOfBirth"
},
"ContactDetails" :
{
"type" : "object",
"o:length" : 128,
"o:preferred_column_name" : "DATA$ContactDetails",
"properties" :
{
"Email" :
{
"type" : "string",
"o:length" : 32,
"o:preferred_column_name" : "DATA$Email"
},
"Phone" :
{
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$Phone"
},
"Twitter" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$Twitter"
}
}
}
}
}
SQL>
SELECT JSON_DATAGUIDE(data) dg_doc
FROM json_documents;
DG_DOC
--------------------------------------------------------------------------------
[{"o:path":"$.Job","type":"string","o:length":8},{"o:path":"$.Active","type":"bo
olean","o:length":8},{"o:path":"$.Address","type":"object","o:length":128},{"o:p
ath":"$.Address.City","type":"string","o:length":8},{"o:path":"$.Address.Street"
,"type":"string","o:length":16},{"o:path":"$.Address.Country","type":"string","o
:length":2},{"o:path":"$.Address.Postcode","type":"string","o:length":8},{"o:pat
h":"$.LastName","type":"string","o:length":4},{"o:path":"$.FirstName","type":"st
ring","o:length":8},{"o:path":"$.DateOfBirth","type":"string","o:length":16},{"o
:path":"$.ContactDetails","type":"object","o:length":128},{"o:path":"$.ContactDe
tails.Email","type":"string","o:length":32},{"o:path":"$.ContactDetails.Phone","
type":"string","o:length":16},{"o:path":"$.ContactDetails.Twitter","type":"strin
g","o:length":8}]
SQL>
WITH dg_t AS (
SELECT JSON_DATAGUIDE(data) dg_doc
FROM json_documents
)
SELECT jt.*
FROM dg_t,
json_table(dg_doc, '$[*]'
COLUMNS
jpath VARCHAR2(40) PATH '$."o:path"',
type VARCHAR2(10) PATH '$."type"',
tlength NUMBER PATH '$."o:length"') jt
ORDER BY jt.jpath;
JPATH TYPE TLENGTH
---------------------------------------- ---------- ----------
$.Active boolean 8
$.Address object 128
$.Address.City string 8
$.Address.Country string 2
$.Address.Postcode string 8
$.Address.Street string 16
$.ContactDetails object 128
$.ContactDetails.Email string 32
$.ContactDetails.Phone string 16
$.ContactDetails.Twitter string 8
$.DateOfBirth string 16
$.FirstName string 8
$.Job string 8
$.LastName string 4
SQL>
WITH dg_t AS (
SELECT DBMS_JSON.get_index_dataguide(
'json_documents',
'data',
DBMS_JSON.format_flat) AS dg_doc
FROM dual
)
SELECT jt.*
FROM dg_t,
json_table(dg_doc, '$[*]'
COLUMNS
jpath VARCHAR2(40) PATH '$."o:path"',
type VARCHAR2(10) PATH '$."type"',
tlength NUMBER PATH '$."o:length"') jt
ORDER BY jt.jpath;
JPATH TYPE TLENGTH
---------------------------------------- ---------- ----------
$.Active boolean 8
$.Address object 128
$.Address.City string 8
$.Address.Country string 2
$.Address.Postcode string 8
$.Address.Street string 16
$.ContactDetails object 128
$.ContactDetails.Email string 32
$.ContactDetails.Phone string 16
$.ContactDetails.Twitter string 8
$.DateOfBirth string 16
$.FirstName string 8
$.Job string 8
$.LastName string 4
SQL>
EXEC DBMS_STATS.gather_index_stats(USER, 'json_docs_search_idx', estimate_percent => 99);
"Phone" :
{
"type" : "string",
"o:length" : 16,
"o:preferred_column_name" : "DATA$Phone",
"o:frequency" : 100,
"o:low_value" : "",
"o:high_value" : "44 123 123456",
"o:num_nulls" : 0,
"o:last_analyzed" : "2018-01-01T13:12:30"
},
"Twitter" :
{
"type" : "string",
"o:length" : 8,
"o:preferred_column_name" : "DATA$Twitter",
"o:frequency" : 50,
"o:low_value" : "@johndoe",
"o:high_value" : "@johndoe",
"o:num_nulls" : 0,
"o:last_analyzed" : "2018-01-01T13:12:30"
}
SET LINESIZE 160
WITH dg_t AS (
SELECT DBMS_JSON.get_index_dataguide(
'json_documents',
'data',
DBMS_JSON.format_flat) AS dg_doc
FROM dual
)
SELECT jt.*
FROM dg_t,
json_table(dg_doc, '$[*]'
COLUMNS
jpath VARCHAR2(30) PATH '$."o:path"',
type VARCHAR2(10) PATH '$."type"',
tlength NUMBER PATH '$."o:length"',
frequency NUMBER PATH '$."o:frequency"',
low_value VARCHAR2(25) PATH '$."o:low_value"',
high_value VARCHAR2(25) PATH '$."o:high_value"',
num_nulls NUMBER PATH '$."o:num_nulls"',
last_analyzed VARCHAR2(20) PATH '$."o:last_analyzed"') jt
ORDER BY jt.jpath;
JPATH TYPE TLENGTH FREQUENCY LOW_VALUE HIGH_VALUE NUM_NULLS LAST_ANALYZED
------------------------------ ---------- ---------- ---------- ------------------------- ------------------------- ---------- --------------------
$.Active boolean 8 100 true false 0 2018-01-01T13:17:50
$.Address object 128 100 2018-01-01T13:17:50
$.Address.City string 8 100 My City My City 0 2018-01-01T13:17:50
$.Address.Country string 2 100 UK UK 0 2018-01-01T13:17:50
$.Address.Postcode string 8 100 A12 34B A12 34B 0 2018-01-01T13:17:50
$.Address.Street string 16 100 99 My Street 100 My Street 0 2018-01-01T13:17:50
$.ContactDetails object 128 100 2018-01-01T13:17:50
$.ContactDetails.Email string 32 100 [email protected] [email protected] 0 2018-01-01T13:17:50
$.ContactDetails.Phone string 16 100 44 123 123456 0 2018-01-01T13:17:50
$.ContactDetails.Twitter string 8 50 @johndoe @johndoe 0 2018-01-01T13:17:50
$.DateOfBirth string 16 100 01-JAN-1980 01-JAN-1982 0 2018-01-01T13:17:50
$.FirstName string 8 100 John Jayne 0 2018-01-01T13:17:50
$.Job string 8 100 Clerk Manager 0 2018-01-01T13:17:50
$.LastName string 4 100 Doe Doe 0 2018-01-01T13:17:50
14 rows selected.
SQL>