SlideShare a Scribd company logo
1 of 19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON And
The Oracle Database
1
Maria Colgan
Master Product Manager
Oracle Database Server Technologies
June 2018
JEFF
@SQLMaria
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What is JSON?
• JSON stands for JavaScript Object Notation
• It’s a "lightweight", readable data interchange format that’s language
independent
• Most popular data format for new web applications
• Instead of creating an entity relationship model to define all of the data
the application needs and then mapping it to a set of relational tables
• Storing JSON documents in the database greatly simplifies application
development as the same schema-less data representation can be use in
Application and the Database
P
u
b
l
i
c
3
{}
JSON
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 4
What is JSON?
{"id":1,
"name":"Century 16",
"location":{"street":"Main St",
"city":"Redwood",
"zipCode":"94607",
"state":"CA",
"phoneNumber":null
},
"ticketPrice":{"adultPrice":14.95,
"childPrice":9.95,
"seniorPrice":9.95
}
}
Public
• A data format that consists of one or more
name value pairs enclosed in curly brackets
• The name is always a string and is separated
from the value by a colon
• A value can be a number, string, true, false
null, an object or array
• E.g. location is an object as it has random set of
name value pairs nested inside , enclosed in { }
• An array is an ordered list of related items which
could be JSON objects and is enclosed in [ ]
• Each pair is separated by a comma
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 5
Storing JSON in the Oracle Database
Table containing JSON documents
Public
• Oracle stores JSON in table columns
• No special data type
• Can be VARCHAR2, BLOB or CLOB
• JSON supported by all Oracle features
• Analytics, Encryption, In-Memory, RAC,
Replication, Parallel SQL, …
• Plus can index any JSON element
CREATE TABLE theater
(
theater_id VARCHAR2(255),
json_document BLOB
);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6
Storing JSON in the Oracle Database
Table containing JSON documents
Public
• Oracle stores JSON in table columns
• No special data type
• Can be VARCHAR2, BLOB or CLOB
• JSON supported by all Oracle features
• Analytics, Encryption, In-Memory, RAC,
Replication, Parallel SQL, …
• Plus can index any JSON element
• IS JSON check constraint enforces
lax JSON syntax by default
• Does not require NAME attributes
to be in double quotes
CREATE TABLE theater
(
theater_id VARCHAR2(255),
json_document BLOB
CONSTRAINT is_json CHECK
(json_document IS JSON)
);
{"id":1,
"name":"Century 16",
}
{id:1,
name:"Century 16",
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 7
Storing JSON in the Oracle Database
Table containing JSON documents
Public
• Oracle stores JSON in table columns
• No special data type
• Can be VARCHAR2, BLOB or CLOB
• JSON supported by all Oracle features
• Analytics, Encryption, In-Memory, RAC,
Replication, Parallel SQL, …
• Plus can index any JSON element
• IS JSON check constraint enforces
lax JSON syntax by default
• To enforce strict JSON syntax add
(STRICT)
CREATE TABLE theater
(
theater_id VARCHAR2(255),
json_document BLOB
CONSTRAINT is_json CHECK
(json_document IS JSON (STRICT))
);
{"id":1,
"name":"Century 16",
}
{id:1,
name:"Century 16",
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Storing JSON in the Oracle Database
• VARCHAR2
Best performance, easy to retrieve via SELECT
Limited max size of 32k only (with MAX_STRING_SIZE=EXTENDED)
BLOB
Best LOB performance but not as fast as VARCHAR2
Unlimited size, not as easy to retrieve via SELECT
No potential characterset conversion
CLOB
Unlimited size, easy to retrieve via SELECT
Potential characterset conversion (from 1 byte UTF-8 to 2 byte USC-2,
double space)
Potential bigger size on disk
P
u
b
l
i
c
8
Which data type to pick?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Inserting JSON in the Oracle Database
• JSON can be inserted into the Oracle Database using all of the standard
interfaces
– Conventional DML - single record transactions
– Bulk data loads via an API
– Import or Data Pumped in
• JSON is supported in every driver
– Via the same routines used to insert a regular VARCHAR2 or LOB
P
u
b
l
i
c
9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Inserting JSON
P
u
b
l
i
c
10
BLOB
INSERT INTO theaters (theater_name, json_document) VALUES
('Century_16_Redwood',
utl_raw.cast_to_raw('{"id":1,
"name":"Century 16",
"location":{"street":"Main St",
"city":"Redwood",
"zipCode":"94607",
"state":"CA",
"phoneNumber":null
}
}')
);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Benefit
• Checks each entry is a
valid JSON document
• Easy dot notation syntax
when querying JSON
Impact
• Slightly slower ingestion
of JSON documents due
to parsing
Solution : Create the constraint disabled
CONSTRAINT is_json CHECK (json_document IS JSON) DISABLE
Benefits and Impact of IS JSON Constraint on Ingest
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 12
Native SQL Support for JSON
12.2 JSON
Public
SELECT
t.json_document.location.city
FROM theater t;
Location
--------------------
Los Angeles
New York
San Francisco
Redwood
SQL> desc THEATER
NAME TYPE
------------------ -----------
JSON_DOCUMENT BLOB
Table containing JSON documents
{"id":1,
"name":"Century 16",
"location":{"street":"Main St",
"city":"Redwood",
"zipCode":"94607",
"state":"CA",
"phoneNumber":null
}
}
• JSON can be queried using simple SQL dot
notation, requires IS JSON check
constraint and table alias
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 13
Alternative Mechanisms for Querying JSON
Public
SELECT
JSON_VALUE(t.json_document,
'$.location.city') City
FROM theater t;
City
--------------------
Los Angeles
New York
San Francisco
Redwood
SQL> desc THEATER
NAME TYPE
------------------ -----------
JSON_DOCUMENT BLOB
Table containing JSON documents
• Without IS JSON constraint you need to
use the JSON_VALUE function to query
JSON
{"id":1,
"name":"Century 16",
"location":{"street":"Main St",
"city":"Redwood",
"zipCode":"94607",
"state":"CA",
"phoneNumber":null
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Data Guide : Understanding Your JSON Documents
• Metadata discovery: discovers the structure of
collection of JSON documents
– Optional: deep analysis of JSON for List of Values, ranges,
sizing etc.
• Automatically Generates
– Virtual columns
– Relational views
• De-normalized relational views for arrays
– Reports/Synopsis of JSON structure
14
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15
SQL> SELECT JSON_DATAGUIDE(t.json_documents)
FROM theater t;
JSON_DATAGUIDE(T.JSON_DOCUMENTS)
----------------------------------------------------------------------
[ {"o:path": "$.Id", "type": ”number", "o:length": 132},
{"o:path": "$.Name", "type": "string", "o:length": 256},
{"o:path": "$.Location", "type": ”object", "o:length": 64 },
{"o:path": "$.Location.Street", "type": ”number", "o:length": 132},
....
{"o:path": "$.Tickets", "type": ”object", "o:length": 64 },
{"o:path": "$.Tickets. AdultPrice","type": ”number", "o:length": 5 },
....
]
Data Guide : Understanding Your JSON Documents
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 16
Oracle Database 12c as a Document Store
12.2 JSON DataGuide – Automatic Schema Inference
Table containing
JSON documents
JSON DataGuide Table enhanced with
virtual columns
SQL> desc MOVIE_TICKETS
NAME TYPE
--------------------- -----------
BOOKING_ID RAW(16)
BOOKING_TIME TIMESTAMP(6)
BOOKING_DETAILS VARCHAR2(4000)
BOOKING_DETAILS$Movie VARCHAR2(16)
BOOKING_DETAILS$Theater VARCHAR2(16)
BOOKING_DETAILS$Adults NUMBER
BOOKING_DETAILS$Time VARCHAR2(32)
DBMS_JSON.
ADD_VIRTUAL_COLUMNS
( 'MOVIE_TICKETS',
'BOOKING_DETAILS');
Public
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL> ALTER TABLE theater ADD city AS
(JSON_VALUE(json_document, '$.location.city'));
SQL> ALTER TABLE theater ADD state AS
(JSON_VALUE(json_document, '$.location.state'));
SQL> ALTER TABLE theater ADD ticketamount AS
(JSON_VALUE(json_document,
'$.ticketPrice.adultPrice'));
17
Manually Create Virtual Columns to make it Easier for Users
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Query JSON with Relational Data
SQL> SELECT t.theater_id,
t.json_document.location.city,
m.movie_name,
SUM(TO_NUMBER(t.json_document.ticketPrice.adultPrice)) total
FROM theater t,
movies m
WHERE m.theater_name = t.json_document.theater_name
GROUP BY t.theater_id,
t.json_document.location.city
ORDER BY total Desc
FETCH FIRST 10 ROWS ONLY;
18
FETCH FIRST 10 ROWS ONLY
• New syntax to limit
number of rows returned
• Replaces SELECT * FROM
WHERE ROWNUM<11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
JSON Search Index : A universal index for JSON content
• Search on JSON attribute names and path values
• Range searches on numeric values within JSON documents
• Full text searches with all the power of Oracle Text
– Full boolean search capabilities (and, or, and not) together with phrase search,
proximity search and "within field" searches.
– Inexact queries: fuzzy match, soundex and name search.
– Automatic linguistic stemming for 32 languages
19
CREATE SEARCH INDEX json_search_index
ON customers (json_document) FOR JSON;
Try it out at : https://livesql.oracle.com/apex/livesql/file/content_FBP0D2WB6CADVAYBMTRCJW3P2.html
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Don’t be afraid of JSON ….
20
…. After all it’s really only a varchar

More Related Content

What's hot

ORDS - Oracle REST Data Services
ORDS - Oracle REST Data ServicesORDS - Oracle REST Data Services
ORDS - Oracle REST Data ServicesJustin Michael Raj
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentationritika1
 
API Asynchrones en Java 8
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8José Paumard
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New FeaturesHaim Michael
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring BootTrey Howard
 
PostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performancePostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performanceVladimir Sitnikov
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11 Knoldus Inc.
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfJosé Paumard
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket ProgrammingVipin Yadav
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJSunil OS
 

What's hot (20)

ORDS - Oracle REST Data Services
ORDS - Oracle REST Data ServicesORDS - Oracle REST Data Services
ORDS - Oracle REST Data Services
 
Spring boot
Spring bootSpring boot
Spring boot
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
API Asynchrones en Java 8
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Spring Core
Spring CoreSpring Core
Spring Core
 
PostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performancePostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performance
 
Core java
Core javaCore java
Core java
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdf
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
JSON
JSONJSON
JSON
 
JDBC
JDBCJDBC
JDBC
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 

Similar to JSON and the Oracle Database

Json in 18c and 19c
Json in 18c and 19cJson in 18c and 19c
Json in 18c and 19cstewashton
 
JSON in 18c and 19c
JSON in 18c and 19cJSON in 18c and 19c
JSON in 18c and 19cstewashton
 
JSON in der Oracle Datenbank
JSON in der Oracle DatenbankJSON in der Oracle Datenbank
JSON in der Oracle DatenbankUlrike Schwinn
 
JSON Support in DB2 for z/OS
JSON Support in DB2 for z/OSJSON Support in DB2 for z/OS
JSON Support in DB2 for z/OSJane Man
 
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseUKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseMarco Gralike
 
PostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsPostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsNicholas Kiraly
 
Power JSON with PostgreSQL
Power JSON with PostgreSQLPower JSON with PostgreSQL
Power JSON with PostgreSQLEDB
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cJim Czuprynski
 
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory DatabaseOracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory DatabaseMarco Gralike
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5Keshav Murthy
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0Keshav Murthy
 
Couchbase Data Platform | Big Data Demystified
Couchbase Data Platform | Big Data DemystifiedCouchbase Data Platform | Big Data Demystified
Couchbase Data Platform | Big Data DemystifiedOmid Vahdaty
 
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...Jim Czuprynski
 
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Tammy Bednar
 
Do More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the EnterpriseDo More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the EnterpriseEDB
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the RoadmapEDB
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsMarko Gorički
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridVinay Kumar
 

Similar to JSON and the Oracle Database (20)

Json in 18c and 19c
Json in 18c and 19cJson in 18c and 19c
Json in 18c and 19c
 
JSON in 18c and 19c
JSON in 18c and 19cJSON in 18c and 19c
JSON in 18c and 19c
 
JSON in der Oracle Datenbank
JSON in der Oracle DatenbankJSON in der Oracle Datenbank
JSON in der Oracle Datenbank
 
JSON Support in DB2 for z/OS
JSON Support in DB2 for z/OSJSON Support in DB2 for z/OS
JSON Support in DB2 for z/OS
 
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseUKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
 
PostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsPostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and Operators
 
Power JSON with PostgreSQL
Power JSON with PostgreSQLPower JSON with PostgreSQL
Power JSON with PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
 
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory DatabaseOracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory Database
 
Introduction to Yasson
Introduction to YassonIntroduction to Yasson
Introduction to Yasson
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0
 
Couchbase Data Platform | Big Data Demystified
Couchbase Data Platform | Big Data DemystifiedCouchbase Data Platform | Big Data Demystified
Couchbase Data Platform | Big Data Demystified
 
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...
JSON, A Splash of SODA, and a SQL Chaser: Real-World Use Cases for Autonomous...
 
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
 
Do More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the EnterpriseDo More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the Enterprise
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and Handlebars
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug Madrid
 

More from Maria Colgan

Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptxFive_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptxMaria Colgan
 
Part4 Influencing Execution Plans with Optimizer Hints
Part4 Influencing Execution Plans with Optimizer HintsPart4 Influencing Execution Plans with Optimizer Hints
Part4 Influencing Execution Plans with Optimizer HintsMaria Colgan
 
Part3 Explain the Explain Plan
Part3 Explain the Explain PlanPart3 Explain the Explain Plan
Part3 Explain the Explain PlanMaria Colgan
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsMaria Colgan
 
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerPart1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerMaria Colgan
 
Ground Breakers Romania: Oracle Autonomous Database
Ground Breakers Romania: Oracle Autonomous DatabaseGround Breakers Romania: Oracle Autonomous Database
Ground Breakers Romania: Oracle Autonomous DatabaseMaria Colgan
 
Ground Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planGround Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planMaria Colgan
 
What to Expect From Oracle database 19c
What to Expect From Oracle database 19cWhat to Expect From Oracle database 19c
What to Expect From Oracle database 19cMaria Colgan
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_planMaria Colgan
 
Beginners guide to_optimizer
Beginners guide to_optimizerBeginners guide to_optimizer
Beginners guide to_optimizerMaria Colgan
 
The Changing Role of a DBA in an Autonomous World
The Changing Role of a DBA in an Autonomous WorldThe Changing Role of a DBA in an Autonomous World
The Changing Role of a DBA in an Autonomous WorldMaria Colgan
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory OverivewMaria Colgan
 
Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesMaria Colgan
 
Five Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingFive Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingMaria Colgan
 
Harnessing the Power of Optimizer Hints
Harnessing the Power of Optimizer HintsHarnessing the Power of Optimizer Hints
Harnessing the Power of Optimizer HintsMaria Colgan
 
Oracle optimizer bootcamp
Oracle optimizer bootcampOracle optimizer bootcamp
Oracle optimizer bootcampMaria Colgan
 
What_to_expect_from_oracle_database_12c
What_to_expect_from_oracle_database_12cWhat_to_expect_from_oracle_database_12c
What_to_expect_from_oracle_database_12cMaria Colgan
 
Oracle database 12c_and_DevOps
Oracle database 12c_and_DevOpsOracle database 12c_and_DevOps
Oracle database 12c_and_DevOpsMaria Colgan
 

More from Maria Colgan (19)

Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptxFive_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
 
Part5 sql tune
Part5 sql tunePart5 sql tune
Part5 sql tune
 
Part4 Influencing Execution Plans with Optimizer Hints
Part4 Influencing Execution Plans with Optimizer HintsPart4 Influencing Execution Plans with Optimizer Hints
Part4 Influencing Execution Plans with Optimizer Hints
 
Part3 Explain the Explain Plan
Part3 Explain the Explain PlanPart3 Explain the Explain Plan
Part3 Explain the Explain Plan
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer Statistics
 
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerPart1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the Optimizer
 
Ground Breakers Romania: Oracle Autonomous Database
Ground Breakers Romania: Oracle Autonomous DatabaseGround Breakers Romania: Oracle Autonomous Database
Ground Breakers Romania: Oracle Autonomous Database
 
Ground Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planGround Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_plan
 
What to Expect From Oracle database 19c
What to Expect From Oracle database 19cWhat to Expect From Oracle database 19c
What to Expect From Oracle database 19c
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
Beginners guide to_optimizer
Beginners guide to_optimizerBeginners guide to_optimizer
Beginners guide to_optimizer
 
The Changing Role of a DBA in an Autonomous World
The Changing Role of a DBA in an Autonomous WorldThe Changing Role of a DBA in an Autonomous World
The Changing Role of a DBA in an Autonomous World
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory Overivew
 
Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied Packages
 
Five Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingFive Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your Indexing
 
Harnessing the Power of Optimizer Hints
Harnessing the Power of Optimizer HintsHarnessing the Power of Optimizer Hints
Harnessing the Power of Optimizer Hints
 
Oracle optimizer bootcamp
Oracle optimizer bootcampOracle optimizer bootcamp
Oracle optimizer bootcamp
 
What_to_expect_from_oracle_database_12c
What_to_expect_from_oracle_database_12cWhat_to_expect_from_oracle_database_12c
What_to_expect_from_oracle_database_12c
 
Oracle database 12c_and_DevOps
Oracle database 12c_and_DevOpsOracle database 12c_and_DevOps
Oracle database 12c_and_DevOps
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

JSON and the Oracle Database

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON And The Oracle Database 1 Maria Colgan Master Product Manager Oracle Database Server Technologies June 2018 JEFF @SQLMaria
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | What is JSON? • JSON stands for JavaScript Object Notation • It’s a "lightweight", readable data interchange format that’s language independent • Most popular data format for new web applications • Instead of creating an entity relationship model to define all of the data the application needs and then mapping it to a set of relational tables • Storing JSON documents in the database greatly simplifies application development as the same schema-less data representation can be use in Application and the Database P u b l i c 3 {} JSON
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 4 What is JSON? {"id":1, "name":"Century 16", "location":{"street":"Main St", "city":"Redwood", "zipCode":"94607", "state":"CA", "phoneNumber":null }, "ticketPrice":{"adultPrice":14.95, "childPrice":9.95, "seniorPrice":9.95 } } Public • A data format that consists of one or more name value pairs enclosed in curly brackets • The name is always a string and is separated from the value by a colon • A value can be a number, string, true, false null, an object or array • E.g. location is an object as it has random set of name value pairs nested inside , enclosed in { } • An array is an ordered list of related items which could be JSON objects and is enclosed in [ ] • Each pair is separated by a comma
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 5 Storing JSON in the Oracle Database Table containing JSON documents Public • Oracle stores JSON in table columns • No special data type • Can be VARCHAR2, BLOB or CLOB • JSON supported by all Oracle features • Analytics, Encryption, In-Memory, RAC, Replication, Parallel SQL, … • Plus can index any JSON element CREATE TABLE theater ( theater_id VARCHAR2(255), json_document BLOB );
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6 Storing JSON in the Oracle Database Table containing JSON documents Public • Oracle stores JSON in table columns • No special data type • Can be VARCHAR2, BLOB or CLOB • JSON supported by all Oracle features • Analytics, Encryption, In-Memory, RAC, Replication, Parallel SQL, … • Plus can index any JSON element • IS JSON check constraint enforces lax JSON syntax by default • Does not require NAME attributes to be in double quotes CREATE TABLE theater ( theater_id VARCHAR2(255), json_document BLOB CONSTRAINT is_json CHECK (json_document IS JSON) ); {"id":1, "name":"Century 16", } {id:1, name:"Century 16", }
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 7 Storing JSON in the Oracle Database Table containing JSON documents Public • Oracle stores JSON in table columns • No special data type • Can be VARCHAR2, BLOB or CLOB • JSON supported by all Oracle features • Analytics, Encryption, In-Memory, RAC, Replication, Parallel SQL, … • Plus can index any JSON element • IS JSON check constraint enforces lax JSON syntax by default • To enforce strict JSON syntax add (STRICT) CREATE TABLE theater ( theater_id VARCHAR2(255), json_document BLOB CONSTRAINT is_json CHECK (json_document IS JSON (STRICT)) ); {"id":1, "name":"Century 16", } {id:1, name:"Century 16", }
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Storing JSON in the Oracle Database • VARCHAR2 Best performance, easy to retrieve via SELECT Limited max size of 32k only (with MAX_STRING_SIZE=EXTENDED) BLOB Best LOB performance but not as fast as VARCHAR2 Unlimited size, not as easy to retrieve via SELECT No potential characterset conversion CLOB Unlimited size, easy to retrieve via SELECT Potential characterset conversion (from 1 byte UTF-8 to 2 byte USC-2, double space) Potential bigger size on disk P u b l i c 8 Which data type to pick?
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Inserting JSON in the Oracle Database • JSON can be inserted into the Oracle Database using all of the standard interfaces – Conventional DML - single record transactions – Bulk data loads via an API – Import or Data Pumped in • JSON is supported in every driver – Via the same routines used to insert a regular VARCHAR2 or LOB P u b l i c 9
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Inserting JSON P u b l i c 10 BLOB INSERT INTO theaters (theater_name, json_document) VALUES ('Century_16_Redwood', utl_raw.cast_to_raw('{"id":1, "name":"Century 16", "location":{"street":"Main St", "city":"Redwood", "zipCode":"94607", "state":"CA", "phoneNumber":null } }') );
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Benefit • Checks each entry is a valid JSON document • Easy dot notation syntax when querying JSON Impact • Slightly slower ingestion of JSON documents due to parsing Solution : Create the constraint disabled CONSTRAINT is_json CHECK (json_document IS JSON) DISABLE Benefits and Impact of IS JSON Constraint on Ingest
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 12 Native SQL Support for JSON 12.2 JSON Public SELECT t.json_document.location.city FROM theater t; Location -------------------- Los Angeles New York San Francisco Redwood SQL> desc THEATER NAME TYPE ------------------ ----------- JSON_DOCUMENT BLOB Table containing JSON documents {"id":1, "name":"Century 16", "location":{"street":"Main St", "city":"Redwood", "zipCode":"94607", "state":"CA", "phoneNumber":null } } • JSON can be queried using simple SQL dot notation, requires IS JSON check constraint and table alias
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 13 Alternative Mechanisms for Querying JSON Public SELECT JSON_VALUE(t.json_document, '$.location.city') City FROM theater t; City -------------------- Los Angeles New York San Francisco Redwood SQL> desc THEATER NAME TYPE ------------------ ----------- JSON_DOCUMENT BLOB Table containing JSON documents • Without IS JSON constraint you need to use the JSON_VALUE function to query JSON {"id":1, "name":"Century 16", "location":{"street":"Main St", "city":"Redwood", "zipCode":"94607", "state":"CA", "phoneNumber":null } }
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Data Guide : Understanding Your JSON Documents • Metadata discovery: discovers the structure of collection of JSON documents – Optional: deep analysis of JSON for List of Values, ranges, sizing etc. • Automatically Generates – Virtual columns – Relational views • De-normalized relational views for arrays – Reports/Synopsis of JSON structure 14
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15 SQL> SELECT JSON_DATAGUIDE(t.json_documents) FROM theater t; JSON_DATAGUIDE(T.JSON_DOCUMENTS) ---------------------------------------------------------------------- [ {"o:path": "$.Id", "type": ”number", "o:length": 132}, {"o:path": "$.Name", "type": "string", "o:length": 256}, {"o:path": "$.Location", "type": ”object", "o:length": 64 }, {"o:path": "$.Location.Street", "type": ”number", "o:length": 132}, .... {"o:path": "$.Tickets", "type": ”object", "o:length": 64 }, {"o:path": "$.Tickets. AdultPrice","type": ”number", "o:length": 5 }, .... ] Data Guide : Understanding Your JSON Documents
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 16 Oracle Database 12c as a Document Store 12.2 JSON DataGuide – Automatic Schema Inference Table containing JSON documents JSON DataGuide Table enhanced with virtual columns SQL> desc MOVIE_TICKETS NAME TYPE --------------------- ----------- BOOKING_ID RAW(16) BOOKING_TIME TIMESTAMP(6) BOOKING_DETAILS VARCHAR2(4000) BOOKING_DETAILS$Movie VARCHAR2(16) BOOKING_DETAILS$Theater VARCHAR2(16) BOOKING_DETAILS$Adults NUMBER BOOKING_DETAILS$Time VARCHAR2(32) DBMS_JSON. ADD_VIRTUAL_COLUMNS ( 'MOVIE_TICKETS', 'BOOKING_DETAILS'); Public
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL> ALTER TABLE theater ADD city AS (JSON_VALUE(json_document, '$.location.city')); SQL> ALTER TABLE theater ADD state AS (JSON_VALUE(json_document, '$.location.state')); SQL> ALTER TABLE theater ADD ticketamount AS (JSON_VALUE(json_document, '$.ticketPrice.adultPrice')); 17 Manually Create Virtual Columns to make it Easier for Users
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Query JSON with Relational Data SQL> SELECT t.theater_id, t.json_document.location.city, m.movie_name, SUM(TO_NUMBER(t.json_document.ticketPrice.adultPrice)) total FROM theater t, movies m WHERE m.theater_name = t.json_document.theater_name GROUP BY t.theater_id, t.json_document.location.city ORDER BY total Desc FETCH FIRST 10 ROWS ONLY; 18 FETCH FIRST 10 ROWS ONLY • New syntax to limit number of rows returned • Replaces SELECT * FROM WHERE ROWNUM<11
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | JSON Search Index : A universal index for JSON content • Search on JSON attribute names and path values • Range searches on numeric values within JSON documents • Full text searches with all the power of Oracle Text – Full boolean search capabilities (and, or, and not) together with phrase search, proximity search and "within field" searches. – Inexact queries: fuzzy match, soundex and name search. – Automatic linguistic stemming for 32 languages 19 CREATE SEARCH INDEX json_search_index ON customers (json_document) FOR JSON; Try it out at : https://livesql.oracle.com/apex/livesql/file/content_FBP0D2WB6CADVAYBMTRCJW3P2.html
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Don’t be afraid of JSON …. 20 …. After all it’s really only a varchar

Editor's Notes

  1. utl_raw.cast_to_raw is used to convert the string into a BLOB.
  2. table alias (mandatory) followed by a dot, the name of a JSON column, and then the . json_field or . json_field followed by array_step