构建表

create table json_user (
uid int auto_increment,
data json,
primary key(uid)
);

插入数据

insert into json_user values (

null, '{

"name":"lison",

"age":18,

"address":"enjoy"

}' );
insert into json_user values (
null,
'{

"name":"james",

"age":28,

"mail":"james@163.com"

}');

查询数据

①查询所有select*

select * from json_user;

mysql存储json数据_json


②利用json_extract查询json数据

select json_extract(data,'$') as json_data from json_user;

mysql存储json数据_json_02

select json_extract(data,'$.age') as age from json_user;

mysql存储json数据_建表_03