文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 12 种字符集、排序规则、Unicode / 12.9 统一码支持 / 12.9.1 utf8mb4 字符集(4 字节 UTF-8 Unicode 编码)
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

12.9.1 utf8mb4 字符集(4 字节 UTF-8 Unicode 编码)12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)

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, utf8mb4 and utf8mb3 have identical storage characteristics: same code values, same encoding, same length.

  • 对于补充字符,utf8mb4 需要四个字节来存储,而 utf8mb3 根本无法存储该字符。在将 utf8mb3 列转换为 utf8mb4 时,无需担心补充字符的转换,因为根本不存在。For a supplementary character, utf8mb4 requires four bytes to store it, whereas utf8mb3 cannot store the character at all. When converting utf8mb3 columns to utf8mb4, 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.