-- 第十二章 数据类型
-- 字符串类型
-- char 固定长度,州的缩写
-- varchar 可变长度,最大是65535 用户名密码-varchar(50);varchar(255)地址
-- mediumtext 最大为16mb
-- longtext 最大为4GB
-- 英文字母1B,中文3B
-- bool类型
-- boolean
-- 枚举类型和集合
-- json类型,可存储多个健值对alter
-- update products
-- set properties = '
-- {
-- "dimensions":[1,2,3],
-- "weight":10,
-- "manufacturer":{"name":"sony"}
-- }
-- '
-- where product_id = 1;
update products
set properties = json_object(
'weight',10,
'dimension',json_array(1,2,3),
'manufacturer',json_object('name','sony')
)
where product_id = 1;
-- json_set更新属性而不是重新设置对象
update products
set properties = json_set(
properties,
'$.weight',20,
'$.age',10
)
where product_id = 1;
-- json_remove删除一个或多个属性
update products
set properties = json_remove(
properties,-- json对象
'$.age'-- 修改并返回新的对象
)
where product_id = 1;
-- select product_id,json_extract(properties,'$.weight') as weight-- 提取重量,$表示当前的json文档
-- from products
-- where product_id = 1;
-- select product_id,properties-> '$.weight' -- 提取重量
-- from products
-- where product_id = 1;
-- select product_id,properties-> '$.dimensions[0]' -- 提取的是数组的第一个元素
-- from products
-- where product_id = 1;
-- select product_id,properties->> '$.manufacturer.name' -- 用点运算符来访问对象的单个属性 >得到的不加双引号
-- from products
-- where product_id = 1;
select product_id,properties -- 用点运算符来访问对象的单个属性 >得到的不加双引号
from products
where product_id = 1;
-- 概念模型:不能提供存储数据的结构,只代表业务实体及其关系
-- 逻辑模型:能了解什么结构或什么表需要用来存储数据,用到的实体会以表格形式存储