SHOW COLLATION [LIKE 'pattern
' | WHEREexpr
]
This statement lists collations supported by the server. 此语句列出服务器支持的排序规则。By default, the output from 默认情况下,SHOW COLLATION
includes all available collations. SHOW COLLATION
的输出包括所有可用的排序规则。The LIKE
clause, if present, indicates which collation names to match. LIKE
子句(如果存在)指示要匹配的排序规则名称。The WHERE
clause can be given to select rows using more general conditions, as discussed in Section 26.8, “Extensions to SHOW Statements”. WHERE
子句可用于使用更一般的条件选择行,如第26.8节,“显示语句的扩展”所述。For example:
mysql> SHOW COLLATION WHERE Charset = 'latin1';
+-------------------+---------+----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+-------------------+---------+----+---------+----------+---------+
| latin1_german1_ci | latin1 | 5 | | Yes | 1 |
| latin1_swedish_ci | latin1 | 8 | Yes | Yes | 1 |
| latin1_danish_ci | latin1 | 15 | | Yes | 1 |
| latin1_german2_ci | latin1 | 31 | | Yes | 2 |
| latin1_bin | latin1 | 47 | | Yes | 1 |
| latin1_general_ci | latin1 | 48 | | Yes | 1 |
| latin1_general_cs | latin1 | 49 | | Yes | 1 |
| latin1_spanish_ci | latin1 | 94 | | Yes | 1 |
+-------------------+---------+----+---------+----------+---------+
SHOW COLLATION
output has these columns:
Collation
The collation name.排序规则名称。
Charset
The name of the character set with which the collation is associated.与排序规则关联的字符集的名称。
Id
The collation ID.排序规则ID。
Default
Whether the collation is the default for its character set.排序规则是否为其字符集的默认值。
Compiled
Whether the character set is compiled into the server.是否将字符集编译到服务器中。
Sortlen
This is related to the amount of memory required to sort strings expressed in the character set.这与排序字符集中表示的字符串所需的内存量有关。
To see the default collation for each character set, use the following statement. 要查看每个字符集的默认排序规则,请使用以下语句。Default
is a reserved word, so to use it as an identifier, it must be quoted as such:Default
是保留字,因此要将其用作标识符,必须将其引用为:
mysql> SHOW COLLATION WHERE `Default` = 'Yes';
+---------------------+----------+----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+---------------------+----------+----+---------+----------+---------+
| big5_chinese_ci | big5 | 1 | Yes | Yes | 1 |
| dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 |
| cp850_general_ci | cp850 | 4 | Yes | Yes | 1 |
| hp8_english_ci | hp8 | 6 | Yes | Yes | 1 |
| koi8r_general_ci | koi8r | 7 | Yes | Yes | 1 |
| latin1_swedish_ci | latin1 | 8 | Yes | Yes | 1 |
...
Collation information is also available from the 排序规则信息也可以从INFORMATION_SCHEMA
COLLATIONS
table. INFORMATION_SCHEMA
排序规则表中获得。See Section 26.3.6, “The INFORMATION_SCHEMA COLLATIONS Table”.请参阅第26.3.6节,“INFORMATION_SCHEMA排序规则表”。