UTF-8,utf8mb4,是不是看起来很迷对于普通的操作和项目总是习惯性的选择UTF-8当我愉快的建了了一张用户表,然后输入
然后就报错了
我在客户方,服务器,数据库使用均是UTF-8,那么为啥会出错呢?先来看看官方文档是这么说的“The character set named utf8 uses a maximum of three bytes per character and contains only BMP characters. The utf8mb4 character set uses a maximum of four bytes per character supports supplementary characters:
For a supplementary character, utf8 cannot store the character at all, whereas utf8mb4 requires four bytes to store it. Because utf8 cannot store the character at all, you have no supplementary characters in utf8 columns and need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.”可以看到MySQL中的UTF-8实际上并不是真正标准的UTF-8,在MySQL中UTF-8使用1-3个字节来表示,而标准的UTF-8使用的是1-4个字节,也就是说,emoji和一些生僻字等无法保存下来,而utf8mb4才是真正标准的UTF-8但是到目前为止,MySQL关于UTF-8和utf8mb4区别有限,而UTF-8支持的1-3字节,也比1-4字节的utf8mb4查询速度更快,空间更加节省,MySQL没有将UTF-8直接改为四个字节其实是因为涉及到MySQL底层存储逻辑,并且现有的使用UTF-8的数据库无法在线升级,干脆知己出了个utf8mb4更为快捷
编辑推荐:
- UTF-8/utf8mb403-01
- mysql insert导致死锁03-01
- Linux下安装MySQL 5.703-01
- 批量3389 批量远程桌面03-01
- 批量远程桌面管理软件 批量vps管理03-01
- 关于自增id,你可能还不知道03-01
- 查询结果集很小,但 Created_tmp_disk_tables 不断增加03-01
- 详解Javascript中Date对象的使用,并实现倒计时函数03-01
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
