Submit Search
Upload
JSON_TABLE -- The best of both worlds
•
2 likes
•
531 views
O
oysteing
Follow
Lightning talk at Percona Live 2018
Read less
Read more
Data & Analytics
Report
Share
Report
Share
1 of 11
Download now
Download to read offline
Recommended
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB
How to Win Friends and Influence People (with Hadoop)
How to Win Friends and Influence People (with Hadoop)
Sam Shah
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHP
Dave Stokes
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
MongoDB
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Alex Sharp
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB
MongoDB .local Chicago 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Chicago 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB
Recommended
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB Europe 2016 - Advanced MongoDB Aggregation Pipelines
MongoDB
How to Win Friends and Influence People (with Hadoop)
How to Win Friends and Influence People (with Hadoop)
Sam Shah
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHP
Dave Stokes
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
MongoDB
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Alex Sharp
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB
MongoDB .local Chicago 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Chicago 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB
More SQL in MySQL 8.0
More SQL in MySQL 8.0
Norvald Ryeng
Data Representation - Day 2
Data Representation - Day 2
blprnt
JSON + Relational – How to Use Hybrid Data Models
JSON + Relational – How to Use Hybrid Data Models
DATAVERSITY
Java 8 Examples
Java 8 Examples
Scott Taylor
Processing & Dataviz
Processing & Dataviz
blprnt
Drupal Mobile
Drupal Mobile
Ruben Teijeiro
JSON Support in Java EE 8
JSON Support in Java EE 8
Dmitry Kornilov
jQuery Datatables With MongDb
jQuery Datatables With MongDb
sliimohara
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
Timur Safin
Ext GWT 3.0 Data Widgets
Ext GWT 3.0 Data Widgets
Sencha
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
Marco Gralike
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory Database
Marco Gralike
Tapping the Data Deluge with R
Tapping the Data Deluge with R
Jeffrey Breen
JSON Support in Java EE 8
JSON Support in Java EE 8
Dmitry Kornilov
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
oysteing
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
oysteing
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
oysteing
POLARDB for MySQL - Parallel Query
POLARDB for MySQL - Parallel Query
oysteing
Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0
oysteing
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
oysteing
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
oysteing
More Related Content
Similar to JSON_TABLE -- The best of both worlds
More SQL in MySQL 8.0
More SQL in MySQL 8.0
Norvald Ryeng
Data Representation - Day 2
Data Representation - Day 2
blprnt
JSON + Relational – How to Use Hybrid Data Models
JSON + Relational – How to Use Hybrid Data Models
DATAVERSITY
Java 8 Examples
Java 8 Examples
Scott Taylor
Processing & Dataviz
Processing & Dataviz
blprnt
Drupal Mobile
Drupal Mobile
Ruben Teijeiro
JSON Support in Java EE 8
JSON Support in Java EE 8
Dmitry Kornilov
jQuery Datatables With MongDb
jQuery Datatables With MongDb
sliimohara
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
Timur Safin
Ext GWT 3.0 Data Widgets
Ext GWT 3.0 Data Widgets
Sencha
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
Marco Gralike
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory Database
Marco Gralike
Tapping the Data Deluge with R
Tapping the Data Deluge with R
Jeffrey Breen
JSON Support in Java EE 8
JSON Support in Java EE 8
Dmitry Kornilov
Similar to JSON_TABLE -- The best of both worlds
(14)
More SQL in MySQL 8.0
More SQL in MySQL 8.0
Data Representation - Day 2
Data Representation - Day 2
JSON + Relational – How to Use Hybrid Data Models
JSON + Relational – How to Use Hybrid Data Models
Java 8 Examples
Java 8 Examples
Processing & Dataviz
Processing & Dataviz
Drupal Mobile
Drupal Mobile
JSON Support in Java EE 8
JSON Support in Java EE 8
jQuery Datatables With MongDb
jQuery Datatables With MongDb
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
Ext GWT 3.0 Data Widgets
Ext GWT 3.0 Data Widgets
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
Oracle Database - JSON and the In-Memory Database
Oracle Database - JSON and the In-Memory Database
Tapping the Data Deluge with R
Tapping the Data Deluge with R
JSON Support in Java EE 8
JSON Support in Java EE 8
More from oysteing
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
oysteing
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
oysteing
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
oysteing
POLARDB for MySQL - Parallel Query
POLARDB for MySQL - Parallel Query
oysteing
Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0
oysteing
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
oysteing
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
oysteing
How to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performance
oysteing
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
oysteing
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
oysteing
How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016
oysteing
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
oysteing
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
oysteing
More from oysteing
(17)
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
POLARDB: A database architecture for the cloud
POLARDB: A database architecture for the cloud
POLARDB for MySQL - Parallel Query
POLARDB for MySQL - Parallel Query
Histogram Support in MySQL 8.0
Histogram Support in MySQL 8.0
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
Common Table Expressions (CTE) & Window Functions in MySQL 8.0
How to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performance
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
Recently uploaded
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Boston Institute of Analytics
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
F sss
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
e4aez8ss
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
📊 Markus Baersch
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
ccctableauusergroup
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
vhwb25kk
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
soniya singh
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
yuu sss
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
hf8803863
How we prevented account sharing with MFA
How we prevented account sharing with MFA
Andrei Kaleshka
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
fhwihughh
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Social Samosa
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
natarajan8993
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Universitat Politècnica de Catalunya
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
jennyeacort
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
Sapana Sha
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
dajasot375
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Sapana Sha
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
Florian Roscheck
Recently uploaded
(20)
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
How we prevented account sharing with MFA
How we prevented account sharing with MFA
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
JSON_TABLE -- The best of both worlds
1.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | JSON_TABLE Øystein Grøvlen Optimizer Geek Oracle April 24, 2018 The Best of Both Worlds
2.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | JSON Data Type CREATE TABLE t1(json_col JSON); INSERT INTO t1 VALUES ( '{ "people": [ { "name":"John Smith", "address":"780 Mission St, San Francisco, CA 94103"}, { "name":"Sally Brown", "address":"75 37th Ave S, St Cloud, MN 94103"}, { "name":"John Johnson", "address":"1262 Roosevelt Trail, Raymond, ME 04071"} ] }' ); 2
3.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | JSON_TABLE SELECT people.* FROM t1, JSON_TABLE(json_col, '$.people[*]' COLUMNS ( name VARCHAR(40) PATH '$.name', address VARCHAR(100) PATH '$.address')) people; 3 Convert JSON documents to relational tables name address John Smith 780 Mission St, San Francisco, CA 94103 Sally Brown 75 37th Ave S, St Cloud, MN 9410 John Johnson 1262 Roosevelt Trail, Raymond, ME 04071
4.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | JSON_TABLE SELECT people.* FROM t1, JSON_TABLE(json_col, '$.people[*]' COLUMNS ( name VARCHAR(40) PATH '$.name', address VARCHAR(100) PATH '$.address')) people; WHERE people.name LIKE 'John%'; 4 Filter JSON data name address John Smith 780 Mission St, San Francisco, CA 94103 John Johnson 1262 Roosevelt Trail, Raymond, ME 04071
5.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | Construct a New JSON Document SELECT JSON_OBJECT("people", JSON_ARRAYAGG(JSON_OBJECT("name", name, "address", address))) json_doc FROM t1, JSON_TABLE(json_col, '$.people[*]' COLUMNS ( name VARCHAR(40) PATH '$.name', address VARCHAR(100) PATH '$.address')) people; WHERE people.name LIKE 'John%'; 5 json_doc {"people": [{"name": "John Smith", "address": "780 Mission St, San Francisco, CA 94103"}, {"name": "John Johnson", "address": "1262 Roosevelt Trail, Raymond, ME 04071"}]}
6.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | 6 JSON_TABLE id father married child_id child age 1 John 1 1 Eric 12 1 John 1 2 Beth 10 2 Paul 0 1 Sarah 9 2 Paul 0 2 Noah 3 2 Paul 0 3 Peter 1 [ { "father":"John", "mother":"Mary", "marriage_date":"2003-12-05", "children": [ { "name":"Eric", "age":12 }, { "name":"Beth", "age":10 } ] }, { "father":"Paul", "mother":"Laura", "children": [ { "name":"Sarah", "age":9}, { "name":"Noah", "age":3} , { "name":"Peter", "age":1} ] } ] Nested arrays
7.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | 7 JSON_TABLE – Nested Arrays id father married child_id child age 1 John 1 1 Eric 12 1 John 1 2 Beth 10 2 Paul 0 1 Sarah 9 2 Paul 0 2 Noah 3 2 Paul 0 3 Peter 1 JSON_TABLE (families, '$[*]' COLUMNS ( id FOR ORDINALITY, father VARCHAR(30) PATH '$.father', married INTEGER EXISTS PATH '$.marriage_date', NESTED PATH '$.children[*]' COLUMNS ( child_id FOR ORDINALITY, child VARCHAR(30) PATH '$.name', age INTEGER PATH '$.age') ) )
8.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | JSON_TABLE SELECT father, COUNT(*) "#children", AVG(age) "age average" FROM t, JSON_TABLE (families, '$[*]' COLUMNS ( id FOR ORDINALITY, father VARCHAR(30) PATH '$.father', NESTED PATH '$.children[*]' COLUMNS (age INTEGER PATH '$.age' ) ) ) AS fam GROUP BY id, father; 8 SQL aggregation on JSON data father #children age average John 2 11.0000 Paul 3 4.3333
9.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | Put Computed Data Back Into JSON Document SELECT JSON_ARRAYAGG(fam_obj) families FROM ( SELECT JSON_MERGE_PATCH(family, JSON_OBJECT("#children", COUNT(*), "avg_age" , AVG(age))) fam_obj FROM t, JSON_TABLE (families, '$[*]' COLUMNS ( id FOR ORDINALITY, family JSON PATH '$', NESTED PATH '$.children[*]' COLUMNS (age INTEGER PATH '$.age' ) ) ) fam GROUP BY id, family) fams; 9
10.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | Modify JSON Objects SELECT JSON_ARRAYAGG(JSON_MERGE_PATCH(JSON_OBJECT("id", id), family)) AS families FROM t, JSON_TABLE (families, '$[*]' COLUMNS ( id FOR ORDINALITY, family JSON PATH '$')) fam; 10 Put IDs in objects families [{"id": 1, "father": "John", "mother": "Mary", "children": [{"age": 12, "name": "Eric"}, {"age": 10, "name": "Beth"}], "marriage_date": "2003-12-05"}, {"id": 2, "father": "Paul", "mother": "Laura", "children": [{"age": 9, "name": "Sarah"}, {"age": 3, "name": "Noah"}, {"age": 1, "name": "Peter"}]}]
11.
Copyright © 2018,
Oracle and/or its affiliates. All rights reserved. | Want to Learn More About New and Upcoming SQL Features? • MySQL 8.0: What is New in Optimizer and Executor? – Manyi Lu – Tuesday 4:50PM-5:15PM; Room GS • Running JavaScript Stored-Programs Inside MySQL Server – Øystein Grøvlen, Vojin Jovanovic, Farhan Tauheed – Wednesday 11:00AM-11:50AM; Room GS 11 Presentations at Percona Live
Download now