SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ドキュメントデータベースとして
MySQLを使う!?
~MySQL JSON UDF~
日本オラクル株式会社
山崎 由章 / MySQL Senior Sales Consultant,
Asia Pacific and Japan
2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。
また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことは
できません。以下の事項は、マテリアルやコード、機能を提供することをコミットメン
ト(確約)するものではないため、購買決定を行う際の判断材料になさらないで下さ
い。オラクル製品に関して記載されている機能の開発、リリースおよび時期につい
ては、弊社の裁量により決定されます。
OracleとJavaは、Oracle Corporation 及びその子会社、関連会社の米国及びその他の国における登録商標です。文中
の社名、商品名等は各社の商標または登録商標である場合があります。
3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Connect 2013の中でこんなセッションが・・・
One More Step to the NoSQL Side: MySQL JSON Functions
4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
http://labs.mysql.com/ にアクセスしてみると・・・
MySQL JSON UDFs !?
5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQLにJSONを扱うための
関数を追加できる!!
※現時点(2013/9/30)では、Lab版(実験版)
6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
セットアップ方法(Linux/UNIX環境の場合) ※詳細はREADMEファイル参照
1. http://labs.mysql.com/ から“MySQL JSON UDFs”を
ダウンロード
2.ダウンロードしたファイルに含まれている“libmy_json_udf.so”を
plugin_dir に配置
(plugin_dirの確認方法:mysql> show global variables like 'plugin_dir';)
3.CREATE FUNCTIONコマンドでUDFを作成
※UDF(User-DefinedFunction:ユーザ定義関数)
7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
mysql> create function json_valid returns integer soname 'libmy_json_udf.so';
mysql> create function json_search returns string soname 'libmy_json_udf.so';
mysql> create function json_extract returns string soname 'libmy_json_udf.so';
mysql> create function json_replace returns string soname 'libmy_json_udf.so';
mysql> create function json_append returns string soname 'libmy_json_udf.so';
mysql> create function json_remove returns string soname 'libmy_json_udf.so';
mysql> create function json_set returns string soname 'libmy_json_udf.so';
mysql> create function json_merge returns string soname 'libmy_json_udf.so';
mysql> create function json_contains_key returns integer soname 'libmy_json_udf.so';
■CREATE FUNCTION
セットアップ方法(Linux/UNIX環境の場合) ※詳細はREADMEファイル参照
8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
補足:READMEファイルのバグ
Linux/UNIX環境に関して、ファンクション作成コマンドが
以下の通り紹介されているが、ライブラリファイルの名前は
‘libmy_json_udf.so’となっている。
ファンクション作成コマンド
create function json_valid returns integer soname 'libmy_json.so';
※http://bugs.mysql.com/bug.php?id=70392
9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
JSON UDFのデモ
10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
サンプルテーブル
mysql> select * from json;
+----+--------------------------------------------------------------------------------+
| id | col1 |
+----+--------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15]} |
| 2 | {"id":2,"Name":"Worker grandmas","price":300000,"Conditions":["factories",15]} |
| 3 | {"id":3,"Name":"Miner grandmas","price":1000000,Conditions:["mines",15]} |
| 4 | {"id":4,"Name":"Yoshiaki Yamasaki"} |
+----+--------------------------------------------------------------------------------+
4 rows in set (0.00 sec)
※id=3の列には、フォーマット間違い有り
(””が抜けている)
※id=4の列はNameだけ
11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_valid:JSONドキュメントのフォーマットチェック
(フォーマットが正しければ1、正しくなければ0)
mysql> select id,json_valid(col1) from json;
+----+------------------+
| id | json_valid(col1) |
+----+------------------+
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 1 |
+----+------------------+
4 rows in set (0.00 sec)
12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_search:値が含まれるキーを検索
mysql> select id,json_search(col1,'"Farmer grandmas"') from json where id=1;
+----+---------------------------------------+
| id | json_search(col1,'"Farmer grandmas"') |
+----+---------------------------------------+
| 1 | Name:: |
+----+---------------------------------------+
1 row in set (0.00 sec)
mysql> select json_search(col1,'"farms"') from json;
+-----------------------------+
| json_search(col1,'"farms"') |
+-----------------------------+
| 0:Conditions:: |
| NULL |
| NULL |
| NULL |
+-----------------------------+
4 rows in set (0.00 sec)
13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_extract:値を抽出
mysql> select id,json_extract(col1,'price') from json;
+----+----------------------------+
| id | json_extract(col1,'price') |
+----+----------------------------+
| 1 | 50000 |
| 2 | 300000 |
| 3 | NULL |
| 4 | NULL |
+----+----------------------------+
4 rows in set (0.00 sec)
mysql> select id,json_extract(col1,'Conditions') from json;
+----+---------------------------------+
| id | json_extract(col1,'Conditions') |
+----+---------------------------------+
| 1 | ["farms",15] |
| 2 | ["factories",15] |
| 3 | NULL |
| 4 | NULL |
+----+---------------------------------+
4 rows in set (0.00 sec)
14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_remove:特定の要素を除去
mysql> select id,json_remove(col1,'price') from json;
+----+------------------------------------------------------------------+
| id | json_remove(col1,'price') |
+----+------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas",,"Conditions":["farms",15]} |
| 2 | {"id":2,"Name":"Worker grandmas",,"Conditions":["factories",15]} |
| 3 | NULL |
| 4 | {"id":4,"Name":"Yoshiaki Yamasaki"} |
+----+------------------------------------------------------------------+
4 rows in set (0.00 sec)
15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_merge:JSONドキュメントのマージ
mysql> select id,json_merge(col1,col1) from json where id=1;
+----+----------------------------------------------------------------------------------------------------------------------------------------------------+
| id | json_merge(col1,col1) |
+----+----------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15], "id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15]} |
+----+----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_contains_key:特定のキーが含まれているか確認
mysql> select id,json_contains_key(col1,'Conditions') from json;
+----+--------------------------------------+
| id | json_contains_key(col1,'Conditions') |
+----+--------------------------------------+
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 0 |
+----+--------------------------------------+
4 rows in set (0.00 sec)
17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_replace:値を置換
mysql> select id,json_replace(col1,'Name','"農家のおばあちゃん"') from json where id=1;
+----+--------------------------------------------------------------------------------------+
| id | json_replace(col1,'Name','"農家のおばあちゃん"') |
+----+--------------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"農家のおばあちゃん","price":50000,"Conditions":["farms",15] |
+----+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
※最後の’}’が欠けている現象については、以下のbugレポートを登録済み
http://bugs.mysql.com/bug.php?id=70486
18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_replace:値を置換
mysql> select id,json_replace(col1,'Conditions','0','10') from json where id=1;
+----+----------------------------------------------------------------------+
| id | json_replace(col1,'Conditions','0','10') |
+----+----------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":[10,15]} |
+----+----------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select id,json_replace(col1,'Conditions','1','10') from json where id=1;
+----+---------------------------------------------------------------------------+
| id | json_replace(col1,'Conditions','1','10') |
+----+---------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",10]} |
+----+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_set:値を設定
mysql> select id,json_set(col1,'Name','"農家のおばあちゃん"') from json where id=1;
+----+--------------------------------------------------------------------------------------+
| id | json_set(col1,'Name','"農家のおばあちゃん"') |
+----+--------------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"農家のおばあちゃん","price":50000,"Conditions":["farms",15] |
+----+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_set:値を設定
mysql> select id,json_set(col1,'Conditions','0','10') from json where id=1;
+----+----------------------------------------------------------------------+
| id | json_set(col1,'Conditions','0','10') |
+----+----------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":[10,15]} |
+----+----------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select id,json_set(col1,'Conditions','1','10') from json where id=1;
+----+---------------------------------------------------------------------------+
| id | json_set(col1,'Conditions','1','10') |
+----+---------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",10]} |
+----+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_set:値を設定
mysql> select id,json_set(col1,'Conditions','2','10') from json where id=1;
+----+-------------------------------------------------------------------------------+
| id | json_set(col1,'Conditions','2','10') |
+----+-------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15, 10]} |
+----+-------------------------------------------------------------------------------+
1 row in set (0.00 sec)
22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
json_append:配列に値を追加
mysql> select id,json_append(col1,'Conditions','2','10') from json where id=1;
+----+-------------------------------------------------------------------------------+
| id | json_append(col1,'Conditions','2','10') |
+----+-------------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15, 10]} |
+----+-------------------------------------------------------------------------------+
1 row in set (0.00 sec)
23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
色々試して、
http://bugs.mysql.com/まで
フィードバックを下さい!!
※今のところ(2013/9/30) JSON UDF専用のカテゴリは無いので、
「MySQL Server: User-defined functions (UDF)」の
カテゴリでレポートを下さい。

Contenu connexe

Tendances

Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试
maclean liu
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynote
jbellis
 
масштабирование в Sql azure
масштабирование в Sql azureмасштабирование в Sql azure
масштабирование в Sql azure
Денис Резник
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012
Alexandre Morgaut
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache Cassandra
DataStax Academy
 

Tendances (20)

MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试
 
Cassandra 3.0 Data Modeling
Cassandra 3.0 Data ModelingCassandra 3.0 Data Modeling
Cassandra 3.0 Data Modeling
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynote
 
Getting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG DenmarkGetting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG Denmark
 
масштабирование в Sql azure
масштабирование в Sql azureмасштабирование в Sql azure
масштабирование в Sql azure
 
20160821 coscup-my sql57docstorelab01
20160821 coscup-my sql57docstorelab0120160821 coscup-my sql57docstorelab01
20160821 coscup-my sql57docstorelab01
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and Merging
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache Cassandra
 
Serial Killers - or Deserialization for fun and profit
Serial Killers - or Deserialization for fun and profitSerial Killers - or Deserialization for fun and profit
Serial Killers - or Deserialization for fun and profit
 
Drools
DroolsDrools
Drools
 
Given Groovy Who Needs Java
Given Groovy Who Needs JavaGiven Groovy Who Needs Java
Given Groovy Who Needs Java
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
MySQL Rises with JSON Support
MySQL Rises with JSON SupportMySQL Rises with JSON Support
MySQL Rises with JSON Support
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
 
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
 

En vedette

En vedette (6)

db tech showcase2016 - MySQLドキュメントストア
db tech showcase2016 - MySQLドキュメントストアdb tech showcase2016 - MySQLドキュメントストア
db tech showcase2016 - MySQLドキュメントストア
 
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
 
業務システムにおけるMongoDB活用法
業務システムにおけるMongoDB活用法業務システムにおけるMongoDB活用法
業務システムにおけるMongoDB活用法
 
MongoDB〜その性質と利用場面〜
MongoDB〜その性質と利用場面〜MongoDB〜その性質と利用場面〜
MongoDB〜その性質と利用場面〜
 
40分でわかるHadoop徹底入門 (Cloudera World Tokyo 2014 講演資料)
40分でわかるHadoop徹底入門 (Cloudera World Tokyo 2014 講演資料) 40分でわかるHadoop徹底入門 (Cloudera World Tokyo 2014 講演資料)
40分でわかるHadoop徹底入門 (Cloudera World Tokyo 2014 講演資料)
 
DMM.comにおけるビッグデータ処理のためのSQL活用術
DMM.comにおけるビッグデータ処理のためのSQL活用術DMM.comにおけるビッグデータ処理のためのSQL活用術
DMM.comにおけるビッグデータ処理のためのSQL活用術
 

Similaire à ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~

Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
mCloud
 
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
Insight Technology, Inc.
 

Similaire à ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~ (20)

MySQL 5.7 + JSON
MySQL 5.7 + JSONMySQL 5.7 + JSON
MySQL 5.7 + JSON
 
Php forum2015 tomas_final
Php forum2015 tomas_finalPhp forum2015 tomas_final
Php forum2015 tomas_final
 
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
 
MySQL 5.7 Tutorial Dutch PHP Conference 2015
MySQL 5.7 Tutorial Dutch PHP Conference 2015MySQL 5.7 Tutorial Dutch PHP Conference 2015
MySQL 5.7 Tutorial Dutch PHP Conference 2015
 
MySQL 5.7. Tutorial - Dutch PHP Conference 2015
MySQL 5.7. Tutorial - Dutch PHP Conference 2015MySQL 5.7. Tutorial - Dutch PHP Conference 2015
MySQL 5.7. Tutorial - Dutch PHP Conference 2015
 
[OSC 2020 Online/Nagoya] MySQLドキュメントストア
[OSC 2020 Online/Nagoya] MySQLドキュメントストア[OSC 2020 Online/Nagoya] MySQLドキュメントストア
[OSC 2020 Online/Nagoya] MySQLドキュメントストア
 
BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7
 
Optimizer percona live_ams2015
Optimizer percona live_ams2015Optimizer percona live_ams2015
Optimizer percona live_ams2015
 
More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12c
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerWellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
 
JSON in der Oracle Datenbank
JSON in der Oracle DatenbankJSON in der Oracle Datenbank
JSON in der Oracle Datenbank
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
 
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
 
Oracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareOracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_share
 
Oracle Diagnostics : Locks and Lock Trees
Oracle Diagnostics :  Locks and Lock TreesOracle Diagnostics :  Locks and Lock Trees
Oracle Diagnostics : Locks and Lock Trees
 
What's New MySQL 8.0?
What's New MySQL 8.0?What's New MySQL 8.0?
What's New MySQL 8.0?
 
Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
 
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
[C12]元気Hadoop! OracleをHadoopで分析しちゃうぜ by Daisuke Hirama
 

Plus de yoyamasaki

Plus de yoyamasaki (20)

MySQL 8.0で強化されたGIS機能のご紹介と周辺ツールとの連携について
MySQL 8.0で強化されたGIS機能のご紹介と周辺ツールとの連携についてMySQL 8.0で強化されたGIS機能のご紹介と周辺ツールとの連携について
MySQL 8.0で強化されたGIS機能のご紹介と周辺ツールとの連携について
 
MySQLドキュメントストアとCTE
MySQLドキュメントストアとCTEMySQLドキュメントストアとCTE
MySQLドキュメントストアとCTE
 
MySQL 8.0で強化されたGIS機能のご紹介+α:「FOSS4G Tokai 2018 」での発表資料
MySQL 8.0で強化されたGIS機能のご紹介+α:「FOSS4G Tokai 2018 」での発表資料 MySQL 8.0で強化されたGIS機能のご紹介+α:「FOSS4G Tokai 2018 」での発表資料
MySQL 8.0で強化されたGIS機能のご紹介+α:「FOSS4G Tokai 2018 」での発表資料
 
MySQL最新情報
MySQL最新情報MySQL最新情報
MySQL最新情報
 
MySQL 8.0で強化されたGIS機能のご紹介:「FOSS4G 2018 Hokkaido」での発表資料
MySQL 8.0で強化されたGIS機能のご紹介:「FOSS4G 2018 Hokkaido」での発表資料MySQL 8.0で強化されたGIS機能のご紹介:「FOSS4G 2018 Hokkaido」での発表資料
MySQL 8.0で強化されたGIS機能のご紹介:「FOSS4G 2018 Hokkaido」での発表資料
 
ついにリリース!! MySQL 8.0 最新情報
ついにリリース!! MySQL 8.0 最新情報ついにリリース!! MySQL 8.0 最新情報
ついにリリース!! MySQL 8.0 最新情報
 
MySQLの公式GUIツール MySQL Workbench
MySQLの公式GUIツール MySQL WorkbenchMySQLの公式GUIツール MySQL Workbench
MySQLの公式GUIツール MySQL Workbench
 
MySQL 開発最新動向
MySQL 開発最新動向MySQL 開発最新動向
MySQL 開発最新動向
 
MySQL最新情報  ※2016年12月
MySQL最新情報  ※2016年12月MySQL最新情報  ※2016年12月
MySQL最新情報  ※2016年12月
 
20160929 inno db_fts_jp
20160929 inno db_fts_jp20160929 inno db_fts_jp
20160929 inno db_fts_jp
 
MySQL 5.7 InnoDB 日本語全文検索(その2)
MySQL 5.7 InnoDB 日本語全文検索(その2)MySQL 5.7 InnoDB 日本語全文検索(その2)
MySQL 5.7 InnoDB 日本語全文検索(その2)
 
Windows環境でのMySQL
Windows環境でのMySQLWindows環境でのMySQL
Windows環境でのMySQL
 
MySQL 5.7 InnoDB 日本語全文検索
MySQL 5.7 InnoDB 日本語全文検索MySQL 5.7 InnoDB 日本語全文検索
MySQL 5.7 InnoDB 日本語全文検索
 
MySQL最新情報 ※2015年9月5日「第1回 関西DB勉強会」での発表資料
MySQL最新情報 ※2015年9月5日「第1回 関西DB勉強会」での発表資料MySQL最新情報 ※2015年9月5日「第1回 関西DB勉強会」での発表資料
MySQL最新情報 ※2015年9月5日「第1回 関西DB勉強会」での発表資料
 
20150920 中国地方db勉強会
20150920 中国地方db勉強会20150920 中国地方db勉強会
20150920 中国地方db勉強会
 
DrupalとMySQL
DrupalとMySQLDrupalとMySQL
DrupalとMySQL
 
Mysql+Mroongaで全文検索
Mysql+Mroongaで全文検索Mysql+Mroongaで全文検索
Mysql+Mroongaで全文検索
 
MySQL Workbench 6.1 の紹介
MySQL Workbench 6.1 の紹介MySQL Workbench 6.1 の紹介
MySQL Workbench 6.1 の紹介
 
MySQL製品概要
MySQL製品概要MySQL製品概要
MySQL製品概要
 
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
 

Dernier

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~

  • 1. 1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~ 日本オラクル株式会社 山崎 由章 / MySQL Senior Sales Consultant, Asia Pacific and Japan
  • 2. 2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。 また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことは できません。以下の事項は、マテリアルやコード、機能を提供することをコミットメン ト(確約)するものではないため、購買決定を行う際の判断材料になさらないで下さ い。オラクル製品に関して記載されている機能の開発、リリースおよび時期につい ては、弊社の裁量により決定されます。 OracleとJavaは、Oracle Corporation 及びその子会社、関連会社の米国及びその他の国における登録商標です。文中 の社名、商品名等は各社の商標または登録商標である場合があります。
  • 3. 3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. MySQL Connect 2013の中でこんなセッションが・・・ One More Step to the NoSQL Side: MySQL JSON Functions
  • 4. 4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. http://labs.mysql.com/ にアクセスしてみると・・・ MySQL JSON UDFs !?
  • 5. 5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. MySQLにJSONを扱うための 関数を追加できる!! ※現時点(2013/9/30)では、Lab版(実験版)
  • 6. 6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. セットアップ方法(Linux/UNIX環境の場合) ※詳細はREADMEファイル参照 1. http://labs.mysql.com/ から“MySQL JSON UDFs”を ダウンロード 2.ダウンロードしたファイルに含まれている“libmy_json_udf.so”を plugin_dir に配置 (plugin_dirの確認方法:mysql> show global variables like 'plugin_dir';) 3.CREATE FUNCTIONコマンドでUDFを作成 ※UDF(User-DefinedFunction:ユーザ定義関数)
  • 7. 7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. mysql> create function json_valid returns integer soname 'libmy_json_udf.so'; mysql> create function json_search returns string soname 'libmy_json_udf.so'; mysql> create function json_extract returns string soname 'libmy_json_udf.so'; mysql> create function json_replace returns string soname 'libmy_json_udf.so'; mysql> create function json_append returns string soname 'libmy_json_udf.so'; mysql> create function json_remove returns string soname 'libmy_json_udf.so'; mysql> create function json_set returns string soname 'libmy_json_udf.so'; mysql> create function json_merge returns string soname 'libmy_json_udf.so'; mysql> create function json_contains_key returns integer soname 'libmy_json_udf.so'; ■CREATE FUNCTION セットアップ方法(Linux/UNIX環境の場合) ※詳細はREADMEファイル参照
  • 8. 8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 補足:READMEファイルのバグ Linux/UNIX環境に関して、ファンクション作成コマンドが 以下の通り紹介されているが、ライブラリファイルの名前は ‘libmy_json_udf.so’となっている。 ファンクション作成コマンド create function json_valid returns integer soname 'libmy_json.so'; ※http://bugs.mysql.com/bug.php?id=70392
  • 9. 9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. JSON UDFのデモ
  • 10. 10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. サンプルテーブル mysql> select * from json; +----+--------------------------------------------------------------------------------+ | id | col1 | +----+--------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15]} | | 2 | {"id":2,"Name":"Worker grandmas","price":300000,"Conditions":["factories",15]} | | 3 | {"id":3,"Name":"Miner grandmas","price":1000000,Conditions:["mines",15]} | | 4 | {"id":4,"Name":"Yoshiaki Yamasaki"} | +----+--------------------------------------------------------------------------------+ 4 rows in set (0.00 sec) ※id=3の列には、フォーマット間違い有り (””が抜けている) ※id=4の列はNameだけ
  • 11. 11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_valid:JSONドキュメントのフォーマットチェック (フォーマットが正しければ1、正しくなければ0) mysql> select id,json_valid(col1) from json; +----+------------------+ | id | json_valid(col1) | +----+------------------+ | 1 | 1 | | 2 | 1 | | 3 | 0 | | 4 | 1 | +----+------------------+ 4 rows in set (0.00 sec)
  • 12. 12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_search:値が含まれるキーを検索 mysql> select id,json_search(col1,'"Farmer grandmas"') from json where id=1; +----+---------------------------------------+ | id | json_search(col1,'"Farmer grandmas"') | +----+---------------------------------------+ | 1 | Name:: | +----+---------------------------------------+ 1 row in set (0.00 sec) mysql> select json_search(col1,'"farms"') from json; +-----------------------------+ | json_search(col1,'"farms"') | +-----------------------------+ | 0:Conditions:: | | NULL | | NULL | | NULL | +-----------------------------+ 4 rows in set (0.00 sec)
  • 13. 13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_extract:値を抽出 mysql> select id,json_extract(col1,'price') from json; +----+----------------------------+ | id | json_extract(col1,'price') | +----+----------------------------+ | 1 | 50000 | | 2 | 300000 | | 3 | NULL | | 4 | NULL | +----+----------------------------+ 4 rows in set (0.00 sec) mysql> select id,json_extract(col1,'Conditions') from json; +----+---------------------------------+ | id | json_extract(col1,'Conditions') | +----+---------------------------------+ | 1 | ["farms",15] | | 2 | ["factories",15] | | 3 | NULL | | 4 | NULL | +----+---------------------------------+ 4 rows in set (0.00 sec)
  • 14. 14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_remove:特定の要素を除去 mysql> select id,json_remove(col1,'price') from json; +----+------------------------------------------------------------------+ | id | json_remove(col1,'price') | +----+------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas",,"Conditions":["farms",15]} | | 2 | {"id":2,"Name":"Worker grandmas",,"Conditions":["factories",15]} | | 3 | NULL | | 4 | {"id":4,"Name":"Yoshiaki Yamasaki"} | +----+------------------------------------------------------------------+ 4 rows in set (0.00 sec)
  • 15. 15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_merge:JSONドキュメントのマージ mysql> select id,json_merge(col1,col1) from json where id=1; +----+----------------------------------------------------------------------------------------------------------------------------------------------------+ | id | json_merge(col1,col1) | +----+----------------------------------------------------------------------------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15], "id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15]} | +----+----------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 16. 16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_contains_key:特定のキーが含まれているか確認 mysql> select id,json_contains_key(col1,'Conditions') from json; +----+--------------------------------------+ | id | json_contains_key(col1,'Conditions') | +----+--------------------------------------+ | 1 | 1 | | 2 | 1 | | 3 | 0 | | 4 | 0 | +----+--------------------------------------+ 4 rows in set (0.00 sec)
  • 17. 17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_replace:値を置換 mysql> select id,json_replace(col1,'Name','"農家のおばあちゃん"') from json where id=1; +----+--------------------------------------------------------------------------------------+ | id | json_replace(col1,'Name','"農家のおばあちゃん"') | +----+--------------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"農家のおばあちゃん","price":50000,"Conditions":["farms",15] | +----+--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) ※最後の’}’が欠けている現象については、以下のbugレポートを登録済み http://bugs.mysql.com/bug.php?id=70486
  • 18. 18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_replace:値を置換 mysql> select id,json_replace(col1,'Conditions','0','10') from json where id=1; +----+----------------------------------------------------------------------+ | id | json_replace(col1,'Conditions','0','10') | +----+----------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":[10,15]} | +----+----------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select id,json_replace(col1,'Conditions','1','10') from json where id=1; +----+---------------------------------------------------------------------------+ | id | json_replace(col1,'Conditions','1','10') | +----+---------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",10]} | +----+---------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 19. 19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_set:値を設定 mysql> select id,json_set(col1,'Name','"農家のおばあちゃん"') from json where id=1; +----+--------------------------------------------------------------------------------------+ | id | json_set(col1,'Name','"農家のおばあちゃん"') | +----+--------------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"農家のおばあちゃん","price":50000,"Conditions":["farms",15] | +----+--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 20. 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_set:値を設定 mysql> select id,json_set(col1,'Conditions','0','10') from json where id=1; +----+----------------------------------------------------------------------+ | id | json_set(col1,'Conditions','0','10') | +----+----------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":[10,15]} | +----+----------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select id,json_set(col1,'Conditions','1','10') from json where id=1; +----+---------------------------------------------------------------------------+ | id | json_set(col1,'Conditions','1','10') | +----+---------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",10]} | +----+---------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 21. 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_set:値を設定 mysql> select id,json_set(col1,'Conditions','2','10') from json where id=1; +----+-------------------------------------------------------------------------------+ | id | json_set(col1,'Conditions','2','10') | +----+-------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15, 10]} | +----+-------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 22. 22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. json_append:配列に値を追加 mysql> select id,json_append(col1,'Conditions','2','10') from json where id=1; +----+-------------------------------------------------------------------------------+ | id | json_append(col1,'Conditions','2','10') | +----+-------------------------------------------------------------------------------+ | 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15, 10]} | +----+-------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
  • 23. 23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 色々試して、 http://bugs.mysql.com/まで フィードバックを下さい!! ※今のところ(2013/9/30) JSON UDF専用のカテゴリは無いので、 「MySQL Server: User-defined functions (UDF)」の カテゴリでレポートを下さい。