什么是字符集
字符集是一套符号和编码的规则,字符串都必须有相应的字符集
校验集是这套符号和编码的校验规则,定义字符排序规则,字符串之间比较的规则
多字节字符间是以字符进行比较,而非以字节为单位进行比较
XXX_bin将字符串中的每一个字符用二进制数据存储,区分大小写
XXX_general_ci不区分大小写
XXX_general_cs区分大小写
不同字符集编码
UTF8:3个字节
UTF8MB4:4个字节
GBK:2个字节
latin1:1个字节
ASCII码:1个字节
字节编码转换:全部通过unicode转换
理解工具字符集
服务端:server=>database=>table=>column
客户端:connection=>result
动态修改客户端字符集:set names utf8;
无法动态修改服务端字符集
varchar(40),varchar(200)区别utf8mb4
40*4=160字节,200*4=800字节
160字节额外需要1个字节存储长度,800字节 额外需要2个字节存储长度
在不跨越255字节的情况下可以用online DDL
varchar(40)如果存储ascii字符,41字节