mysql5 数据类型_MySQL5.7的常用数据类型

目录

Mysql5.7的新特性

Mysql的数值类型

日期和时间类型

字符串类型

数据类型的属性

注:以下图片来源为传智播客

Mysql5.7的新特性

我们知道mysql5.7新增了json的数据类型,下面列出json类型数据的简单操作

1.创建json类型字段

CREATE TABLE `test_table` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`content` json DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

2.Insert

INSERT into test_table VALUES(null,'{"name":"测试1","age":1}');

INSERT into test_table VALUES(null,'{"name":"测试2","age":10}');

3.select

SELECT json_extract(content,'$.name') as name ,json_extract(content,'$.age') as age from test_table

4.替换

update test_table set content=json_replace(content,'$.name',"测1") where json_extract(content,'$.age')=1

5.添加

update test_table set content=json_insert(content,'$.sex',"男") where json_extract(content,'$.age')=1

6.新增

update test_table set content=json_set(content,'$.sex1',"女") where json_extract(content,'$.age')=1

7.删除

update test_table set content=json_remove(content,'$.sex1') where json_extract(content,'$.age')=1

Mysql的数值类型

45ca6d64b1f6bff0fc4a0f386b583326.png

日期和时间类型

ade4f8cf4ca85e8bc359b9dae09783fd.png

字符串类型

5ddc3a34043527054abee831375f582f.png

数据类型的属性

6f3a89d96117f41f50b8414afc08ae16.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值