SlideShare a Scribd company logo
1 of 19
Download to read offline
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

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsEnkitec
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function Prof.Nilesh Magar
 
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]Markus Michalewicz
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries InformationNishant Munjal
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerSteven Feuerstein
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionMarkus Michalewicz
 
Using Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesUsing Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesAnil Nair
 
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
 
Odi tutorial configuração repositórios mestre e trabalho
Odi tutorial   configuração repositórios mestre e trabalhoOdi tutorial   configuração repositórios mestre e trabalho
Odi tutorial configuração repositórios mestre e trabalhoCaio Lima
 
How to find what is making your Oracle database slow
How to find what is making your Oracle database slowHow to find what is making your Oracle database slow
How to find what is making your Oracle database slowSolarWinds
 
Gentle Introduction to Scala
Gentle Introduction to ScalaGentle Introduction to Scala
Gentle Introduction to ScalaFangda Wang
 
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudOracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudMarkus Michalewicz
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.bhavesh lande
 
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...rehaniltifat
 
Pl sql student guide v 1
Pl sql student guide v 1Pl sql student guide v 1
Pl sql student guide v 1Nexus
 
Make Your Application “Oracle RAC Ready” & Test For It
Make Your Application “Oracle RAC Ready” & Test For ItMake Your Application “Oracle RAC Ready” & Test For It
Make Your Application “Oracle RAC Ready” & Test For ItMarkus Michalewicz
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadatarehaniltifat
 

What's hot (20)

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function
 
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL Compiler
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion Edition
 
Using Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesUsing Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC Issues
 
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
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Java & J2EE Coding Conventions
Java & J2EE Coding ConventionsJava & J2EE Coding Conventions
Java & J2EE Coding Conventions
 
Odi tutorial configuração repositórios mestre e trabalho
Odi tutorial   configuração repositórios mestre e trabalhoOdi tutorial   configuração repositórios mestre e trabalho
Odi tutorial configuração repositórios mestre e trabalho
 
SQL
SQLSQL
SQL
 
How to find what is making your Oracle database slow
How to find what is making your Oracle database slowHow to find what is making your Oracle database slow
How to find what is making your Oracle database slow
 
Gentle Introduction to Scala
Gentle Introduction to ScalaGentle Introduction to Scala
Gentle Introduction to Scala
 
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudOracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
 
Pl sql student guide v 1
Pl sql student guide v 1Pl sql student guide v 1
Pl sql student guide v 1
 
Make Your Application “Oracle RAC Ready” & Test For It
Make Your Application “Oracle RAC Ready” & Test For ItMake Your Application “Oracle RAC Ready” & Test For It
Make Your Application “Oracle RAC Ready” & Test For It
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata
 

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
 
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 (18)

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
 
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

Why Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionWhy Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionDEEPRAJ PATHAK
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Introduction-to-Wazuh-and-its-integration.pptx
Introduction-to-Wazuh-and-its-integration.pptxIntroduction-to-Wazuh-and-its-integration.pptx
Introduction-to-Wazuh-and-its-integration.pptxmprakaash5
 
Women in Automation 2024: Career session - explore career paths in automation
Women in Automation 2024: Career session - explore career paths in automationWomen in Automation 2024: Career session - explore career paths in automation
Women in Automation 2024: Career session - explore career paths in automationDianaGray10
 
full stack practical assignment msc cs.pdf
full stack practical assignment msc cs.pdffull stack practical assignment msc cs.pdf
full stack practical assignment msc cs.pdfHulkTheDevil
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Dynamical Context introduction word sensibility orientation
Dynamical Context introduction word sensibility orientationDynamical Context introduction word sensibility orientation
Dynamical Context introduction word sensibility orientationBuild Intuit
 
The work to make the piecework work: An ethnographic study of food delivery w...
The work to make the piecework work: An ethnographic study of food delivery w...The work to make the piecework work: An ethnographic study of food delivery w...
The work to make the piecework work: An ethnographic study of food delivery w...stockholm university
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneUiPathCommunity
 
The Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data EcosystemThe Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data EcosystemSafe Software
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
A PowerPoint Presentation on Vikram Lander pptx
A PowerPoint Presentation on Vikram Lander pptxA PowerPoint Presentation on Vikram Lander pptx
A PowerPoint Presentation on Vikram Lander pptxatharvdev2010
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Arti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfArti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfwill854175
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...BookNet Canada
 
Deliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceDeliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceOpsTree solutions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 

Recently uploaded (20)

Why Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionWhy Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile Evolution
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Introduction-to-Wazuh-and-its-integration.pptx
Introduction-to-Wazuh-and-its-integration.pptxIntroduction-to-Wazuh-and-its-integration.pptx
Introduction-to-Wazuh-and-its-integration.pptx
 
Women in Automation 2024: Career session - explore career paths in automation
Women in Automation 2024: Career session - explore career paths in automationWomen in Automation 2024: Career session - explore career paths in automation
Women in Automation 2024: Career session - explore career paths in automation
 
full stack practical assignment msc cs.pdf
full stack practical assignment msc cs.pdffull stack practical assignment msc cs.pdf
full stack practical assignment msc cs.pdf
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Dynamical Context introduction word sensibility orientation
Dynamical Context introduction word sensibility orientationDynamical Context introduction word sensibility orientation
Dynamical Context introduction word sensibility orientation
 
The work to make the piecework work: An ethnographic study of food delivery w...
The work to make the piecework work: An ethnographic study of food delivery w...The work to make the piecework work: An ethnographic study of food delivery w...
The work to make the piecework work: An ethnographic study of food delivery w...
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyone
 
The Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data EcosystemThe Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data Ecosystem
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
A PowerPoint Presentation on Vikram Lander pptx
A PowerPoint Presentation on Vikram Lander pptxA PowerPoint Presentation on Vikram Lander pptx
A PowerPoint Presentation on Vikram Lander pptx
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Arti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfArti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdf
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
 
Deliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceDeliver Latency Free Customer Experience
Deliver Latency Free Customer Experience
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 

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