utf8mb4 字符集具有以下特性:The utf8mb4 character set has these
characteristics:
支持 BMP 和补充字符。Supports BMP and supplementary characters.
每个多字节字符最多需要四个字节。Requires a maximum of four bytes per multibyte character.
utf8mb4 与 utf8mb3 字符集形成对比,后者仅支持 BMP 字符,并且每个字符最多使用三字节:utf8mb4 contrasts with the
utf8mb3 character set, which supports only
BMP characters and uses a maximum of three bytes per character:
对于 BMP 字符,
utf8mb4和utf8mb3的存储特性相同:相同的代码值、相同的编码、相同的长度。For a BMP character,utf8mb4andutf8mb3have identical storage characteristics: same code values, same encoding, same length.对于补充字符,
utf8mb4需要四个字节来存储,而utf8mb3根本无法存储该字符。在将utf8mb3列转换为utf8mb4时,无需担心补充字符的转换,因为根本不存在。For a supplementary character,utf8mb4requires four bytes to store it, whereasutf8mb3cannot store the character at all. When convertingutf8mb3columns toutf8mb4, you need not worry about converting supplementary characters because there are none.
utf8mb4 是 utf8mb3 的超集,因此对于如下的连接操作,结果的字符集为 utf8mb4,排序规则为 utf8mb4_col:utf8mb4 is a superset of
utf8mb3, so for an operation such as the
following concatenation, the result has character set
utf8mb4 and the collation of
utf8mb4_col:
SELECT CONCAT(utf8mb3_col, utf8mb4_col);
同样,WHERE 子句中的如下比较操作将根据 utf8mb4_col 的排序规则进行:Similarly, the following comparison in the
WHERE clause works according to the collation
of utf8mb4_col:
SELECT * FROM utf8mb3_tbl, utf8mb4_tbl WHERE utf8mb3_tbl.utf8mb3_col = utf8mb4_tbl.utf8mb4_col;
有关多字节字符集相关的数据类型存储信息,请参见 字符串类型存储要求。For information about data type storage as it relates to multibyte character sets, see String Type Storage Requirements.