13.7.7.4 SHOW COLLATION Statement语句

SHOW COLLATION
    [LIKE 'pattern' | WHERE expr]

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:

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排序规则表”