天天看点

mysql数据数据类型

mysql在5.*版本时大量使用以下编码格式:

1)utf8_bin

2)utf8_general_ci

3)utf8_general_cs

utf8_bin将字符串中的每一个字符用二进制数据存储,区分大小写。

utf8_genera_ci不区分大小写,ci为case insensitive的缩写,即大小写不敏感。

utf8_general_cs区分大小写,cs为case sensitive的缩写,即大小写敏感。

在新的mysql中如8.*版本中推荐使用:

utf8mb4 原因请参看以下链接:

https://blog.csdn.net/gf771115/article/details/52946061

https://blog.csdn.net/h_hongchang/article/details/80839184

总结为一句话:使用utf8存在漏洞因此推荐使用mb4

引申出存储规则,默认使用utf8mb4_0900_ai_ci

一般使用:utf8mb4_general_ci和utf8mb4_bin,前者不区分大小写

没有测试但感觉还是utf8mb4+utf8mb4_bin靠谱,可以区分大小写。

链接如下:

https://www.cnblogs.com/exmyth/p/3616672.html

https://segmentfault.com/q/1010000015560802?utm_source=tag-newest

https://segmentfault.com/a/1190000015307793

https://dev.mysql.com/doc/refman/8.0/en/collations-table.html