8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 59%

12.14.4 向 Unicode 字符集添加 UCA 排序规则12.14.4 Adding a UCA Collation to a Unicode Character Set

本节描述了如何通过在 MySQL Index.xml 文件的 <charset> 字符集描述中编写 <collation> 元素来为 Unicode 字符集添加 UCA 排序规则。这里描述的过程不需要重新编译 MySQL。它使用了 Locale Data Markup Language (LDML) 规范的一个子集,该规范可在 http://www.unicode.org/reports/tr35/ 获取。使用这种方法,你不必定义整个排序规则。相反,你从现有的 “base” 排序规则开始,并根据其与基础排序规则的区别来描述新的排序规则。下表列出了可以为其定义 UCA 排序规则的 Unicode 字符集的基础排序规则。无法为 utf16le 创建用户定义的 UCA 排序规则,因为没有 utf16le_unicode_ci 排序规则可以作为这些排序规则的基础。This section describes how to add a UCA collation for a Unicode character set by writing the <collation> element within a <charset> character set description in the MySQL Index.xml file. The procedure described here does not require recompiling MySQL. It uses a subset of the Locale Data Markup Language (LDML) specification, which is available at http://www.unicode.org/reports/tr35/. With this method, you need not define the entire collation. Instead, you begin with an existing “base” collation and describe the new collation in terms of how it differs from the base collation. The following table lists the base collations of the Unicode character sets for which UCA collations can be defined. It is not possible to create user-defined UCA collations for utf16le; there is no utf16le_unicode_ci collation that would serve as the basis for such collations.

表 12.4 用户定义 UCA 排序规则可用的 MySQL 字符集Table 12.4 MySQL Character Sets Available for User-Defined UCA Collations

字符集Character Set 基础排序Base Collation
utf8mb4utf8mb4 utf8mb4_unicode_ci
ucs2 ucs2_unicode_ci
utf16 utf16_unicode_ci
utf32 utf32_unicode_ci

以下各节展示了如何添加使用 LDML 语法定义的排序规则,并提供了 MySQL 支持的 LDML 规则的摘要。The following sections show how to add a collation that is defined using LDML syntax, and provide a summary of LDML rules supported in MySQL.