11.3.1 String Data Type Syntax字符串数据类型语法

The string data types are CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM, and SET.字符串数据类型有CHARVARCHARBINARYVARBINARYBLOBTEXTENUMSET

In some cases, MySQL may change a string column to a type different from that given in a CREATE TABLE or ALTER TABLE statement. 在某些情况下,MySQL可能会将字符串列更改为与CREATE TABLEALTER TABLE语句中给定的类型不同的类型。See Section 13.1.20.7, “Silent Column Specification Changes”.请参阅第13.1.20.7节,“静默列规范变更”

For definitions of character string columns (CHAR, VARCHAR, and the TEXT types), MySQL interprets length specifications in character units. 对于字符串列(CHARVARCHARTEXT类型)的定义,MySQL以字符单位解释长度规范。For definitions of binary string columns (BINARY, VARBINARY, and the BLOB types), MySQL interprets length specifications in byte units.对于二进制字符串列(BINARYVARBINARYBLOB类型)的定义,MySQL以字节为单位解释长度规范。

Column definitions for character string data types CHAR, VARCHAR, the TEXT types, ENUM, SET, and any synonyms) can specify the column character set and collation:字符串数据类型(CHARVARCHARTEXT类型、ENUMSET和任何同义词)的列定义可以指定列字符集和排序规则:

Character column comparison and sorting are based on the collation assigned to the column. 字符列比较和排序基于分配给该列的排序规则。For the CHAR, VARCHAR, TEXT, ENUM, and SET data types, you can declare a column with a binary (_bin) collation or the BINARY attribute to cause comparison and sorting to use the underlying character code values rather than a lexical ordering.对于CHARVARCHARTEXTENUMSET数据类型,可以使用二进制(_bin)排序规则或binary属性声明列,以使比较和排序使用底层字符代码值,而不是词法排序。

For additional information about use of character sets in MySQL, see Chapter 10, Character Sets, Collations, Unicode.有关在MySQL中使用字符集的更多信息,请参阅第10章“字符集,排序规则,Unicode”