mysql day11 第十二章数据类型(部分)

-- 第十二章 数据类型
-- 字符串类型
-- 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;

-- 概念模型:不能提供存储数据的结构,只代表业务实体及其关系
-- 逻辑模型:能了解什么结构或什么表需要用来存储数据,用到的实体会以表格形式存储
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值