background image
10 分钟了解 MySQL5.7 对原生 JSON 的支持与用法
Part1:JSON 格式的支持
MySQL5.7 版本终于支持了原生的 JSON 格式,即将关系型数据库和文档型 NO_SQL 数据库集于
一身。本文接下来将对这特性分别就 MySQL5.7 和 MariaDB10.1 各自实现的方法异同进行介
绍和演示。
Part2:创建相应表结构
[root@HE3 ~]# mysql -V
mysql
Ver 14.14 Distrib 5.7.15, for linux-glibc2.5 (x86_64) using
EditLine
wrapper
1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
mysql>
create database
helei;
Query OK, 1 row affected (0.00 sec)
mysql> use helei;
Database
changed
mysql>
create table
helei (id
int
(10) unsigned
NOT NULL
,context json
d
efault
null
,
primary key
(id));
Query OK, 0
rows
affected (0.02 sec)
mysql> show
create table
helei \G
*************************** 1. row ***************************
Table
: helei
Create Table
:
CREATE TABLE
`helei` (
`id`
int
(10) unsigned
NOT NULL
,
`context` json
DEFAULT
NULL
,
PRIMARY KEY
(`id`)
) ENGINE=InnoDB
DEFAULT
CHARSET=utf8
1 row
in
set
(0.02 sec)
Part3:构造数据&测试
1
2
mysql>
desc
helei;
+
---------+------------------+------+-----+---------+-------+