- 12.3.1 整理规则命名约定12.3.1 Collation Naming Conventions
- 12.3.2 服务器字符集和排序规则12.3.2 Server Character Set and Collation
- 12.3.3 数据库字符集和排序规则12.3.3 Database Character Set and Collation
- 12.3.4 表字符集和排序规则12.3.4 Table Character Set and Collation
- 12.3.5 列字符集和排序规则12.3.5 Column Character Set and Collation
- 12.3.6 字符串字面量字符集和排序规则12.3.6 Character String Literal Character Set and Collation
- 12.3.7 国家字符集12.3.7 The National Character Set
- 12.3.8 字符集引入器12.3.8 Character Set Introducers
- 12.3.9 字符集和排序规则分配示例12.3.9 Examples of Character Set and Collation Assignment
- 12.3.10 与其他数据库管理系统的兼容性12.3.10 Compatibility with Other DBMSs
字符集和排序规则在四个层级上有默认设置:服务器、数据库、表和列。以下各节中的描述可能看起来复杂,但实践中发现,多层级的默认设置会产生自然且明显的结果。There are default settings for character sets and collations at four levels: server, database, table, and column. The description in the following sections may appear complex, but it has been found in practice that multiple-level defaulting leads to natural and obvious results.
CHARACTER SET 用于指定字符集的子句中。CHARSET 可以作为 CHARACTER SET 的同义词使用。CHARACTER SET is used in clauses that specify a
character set. CHARSET can be used as a synonym
for CHARACTER SET.
字符集问题不仅影响数据存储,还会影响客户端程序与 MySQL 服务器之间的通信。如果希望客户端程序使用不同于默认的字符集与服务器进行通信,需要指明所使用的字符集。例如,要使用 latin1 Unicode 字符集,在连接服务器后执行以下语句:Character set issues affect not only data storage, but also
communication between client programs and the MySQL server. If you
want the client program to communicate with the server using a
character set different from the default, you need to indicate
which one. For example, to use the latin1
Unicode character set, issue this statement after connecting to
the server:
SET NAMES 'latin1';
有关客户端/服务器通信中字符集相关问题的更多信息,请参见 第 12.4 节,“连接字符集和排序规则”。For more information about character set-related issues in client/server communication, see Section 12.4, “Connection Character Sets and Collations”.