diff --git a/character-set-and-collation.md b/character-set-and-collation.md index f3dc38a98a932..e60a6594c37ef 100644 --- a/character-set-and-collation.md +++ b/character-set-and-collation.md @@ -77,7 +77,7 @@ SELECT ### Character set and collation naming -A character set can have multiple collations, named in the `_` format. For example, the `utf8mb4` character set has a collation called `utf8mb4_bin`, which is a binary collation for `utf8mb4`. Multiple collation properties can be included in the name, separated by underscores (`_`). +A character set can have multiple collations, named in the `_` format. For example, the `utf8mb4` character set has a collation called `utf8mb4_bin`, which is a binary collation for `utf8mb4`. Multiple collation properties can be included in the name, separated by underscores (`_`). The following table shows the common collation properties and meanings. @@ -159,16 +159,16 @@ SHOW COLLATION WHERE Charset = 'utf8mb4'; ``` ```sql -+--------------------+---------+------+---------+----------+---------+ -| Collation | Charset | Id | Default | Compiled | Sortlen | -+--------------------+---------+------+---------+----------+---------+ -| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 1 | -| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 | -| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | -| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | -| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 1 | -+--------------------+---------+------+---------+----------+---------+ -5 rows in set (0.00 sec) ++--------------------+---------+-----+---------+----------+---------+---------------+ +| Collation | Charset | Id | Default | Compiled | Sortlen | Pad_attribute | ++--------------------+---------+-----+---------+----------+---------+---------------+ +| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 0 | NO PAD | +| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 | NO PAD | +| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | PAD SPACE | +| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | PAD SPACE | +| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 8 | PAD SPACE | ++--------------------+---------+-----+---------+----------+---------+---------------+ +5 rows in set (0.001 sec) ``` For details about the TiDB support of the GBK character set, see [GBK](/character-set-gbk.md). diff --git a/information-schema/information-schema-collations.md b/information-schema/information-schema-collations.md index cdb3f9c4a9af2..9224c8d89a05b 100644 --- a/information-schema/information-schema-collations.md +++ b/information-schema/information-schema-collations.md @@ -7,8 +7,6 @@ summary: Learn the `COLLATIONS` information_schema table. The `COLLATIONS` table provides a list of collations that correspond to character sets in the `CHARACTER_SETS` table. Currently, this table is included only for compatibility with MySQL. -{{< copyable "sql" >}} - ```sql USE information_schema; DESC collations; @@ -20,29 +18,30 @@ DESC collations; +--------------------+-------------+------+------+---------+-------+ | COLLATION_NAME | varchar(32) | YES | | NULL | | | CHARACTER_SET_NAME | varchar(32) | YES | | NULL | | -| ID | bigint(11) | YES | | NULL | | +| ID | bigint | YES | | NULL | | | IS_DEFAULT | varchar(3) | YES | | NULL | | | IS_COMPILED | varchar(3) | YES | | NULL | | -| SORTLEN | bigint(3) | YES | | NULL | | +| SORTLEN | bigint | YES | | NULL | | +| PAD_ATTRIBUTE | varchar(9) | YES | | NULL | | +--------------------+-------------+------+------+---------+-------+ -6 rows in set (0.00 sec) +7 rows in set (0.001 sec) ``` -{{< copyable "sql" >}} - ```sql SELECT * FROM collations WHERE character_set_name='utf8mb4'; ``` ```sql -+--------------------+--------------------+------+------------+-------------+---------+ -| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN | -+--------------------+--------------------+------+------------+-------------+---------+ -| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | -| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | -| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 1 | -+--------------------+--------------------+------+------------+-------------+---------+ -3 rows in set (0.001 sec) ++--------------------+--------------------+------+------------+-------------+---------+---------------+ +| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN | PAD_ATTRIBUTE | ++--------------------+--------------------+------+------------+-------------+---------+---------------+ +| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 0 | NO PAD | +| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 | NO PAD | +| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | PAD SPACE | +| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | PAD SPACE | +| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 8 | PAD SPACE | ++--------------------+--------------------+------+------------+-------------+---------+---------------+ +5 rows in set (0.001 sec) ``` The description of columns in the `COLLATIONS` table is as follows: @@ -53,6 +52,7 @@ The description of columns in the `COLLATIONS` table is as follows: * `IS_DEFAULT`: Whether this collation is the default collation of the character set it belongs to. * `IS_COMPILED`: Whether the character set is compiled into the server. * `SORTLEN`: The minimum length of memory allocated when the collation sorts characters. +* `PAD_ATTRIBUTE`: Whether trailing spaces are ignored during string comparison. `PAD SPACE` means that trailing spaces are ignored (for example, `'abc'` equals `'abc '`), while `NO PAD` means that trailing spaces are significant (for example, `'abc'` does not equal `'abc '`). ## See also diff --git a/sql-statements/sql-statement-show-collation.md b/sql-statements/sql-statement-show-collation.md index a7d1b34e46562..a6c840aaa225f 100644 --- a/sql-statements/sql-statement-show-collation.md +++ b/sql-statements/sql-statement-show-collation.md @@ -87,16 +87,16 @@ SHOW COLLATION WHERE Charset="utf8mb4"; ``` ```sql -+--------------------+---------+-----+---------+----------+---------+ -| Collation | Charset | Id | Default | Compiled | Sortlen | -+--------------------+---------+-----+---------+----------+---------+ -| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 1 | -| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 | -| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | -| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | -| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 1 | -+--------------------+---------+-----+---------+----------+---------+ -5 rows in set (0.00 sec) ++--------------------+---------+-----+---------+----------+---------+---------------+ +| Collation | Charset | Id | Default | Compiled | Sortlen | Pad_attribute | ++--------------------+---------+-----+---------+----------+---------+---------------+ +| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 0 | NO PAD | +| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 | NO PAD | +| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 | PAD SPACE | +| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | PAD SPACE | +| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 8 | PAD SPACE | ++--------------------+---------+-----+---------+----------+---------+---------------+ +5 rows in set (0.001 sec) ``` ## MySQL compatibility