# Character Sets And Collation
__*character set*__
__*collation*__
+ **`Character Set`** is a set of symbols and encodings.
  + All strings belong to a specific character set
  + The default character set in `TiDB` is `utf8mb4`
+ **`Collation`** is a set of rules for comparing characters in a character set to the sort order of characters
  + Affects comparison of characters and strings
  + The default rule in `TiDB` is `utf8mb4_bin`
+ **`SHOW CHARACTER SET`**: Displays all supported character sets
+ **`SHOW COLLATION`**: Show all supported collation

------------------------------------------------------------

```
tidb> show character set;
+---------+-------------------------------------+-------------------+--------+
| Charset | Description                         | Default collation | Maxlen |
+---------+-------------------------------------+-------------------+--------+
| ascii   | US ASCII                            | ascii_bin         |      1 |
| binary  | binary                              | binary            |      1 |
| gbk     | Chinese Internal Code Specification | gbk_chinese_ci    |      2 |
| latin1  | Latin1                              | latin1_bin        |      1 |
| utf8    | UTF-8 Unicode                       | utf8_bin          |      3 |
| utf8mb4 | UTF-8 Unicode                       | utf8mb4_bin       |      4 |
+---------+-------------------------------------+-------------------+--------+
6 rows in set (0.01 sec)

tidb> show collation;
+--------------------+---------+------+---------+----------+---------+
| Collation          | Charset | Id   | Default | Compiled | Sortlen |
+--------------------+---------+------+---------+----------+---------+
| ascii_bin          | ascii   |   65 | Yes     | Yes      |       1 |
| binary             | binary  |   63 | Yes     | Yes      |       1 |
| gbk_bin            | gbk     |   87 |         | Yes      |       1 |
| gbk_chinese_ci     | gbk     |   28 | Yes     | Yes      |       1 |
| latin1_bin         | latin1  |   47 | Yes     | Yes      |       1 |
| utf8_bin           | utf8    |   83 | Yes     | Yes      |       1 |
| utf8_general_ci    | utf8    |   33 |         | Yes      |       1 |
| utf8_unicode_ci    | utf8    |  192 |         | Yes      |       1 |
| utf8mb4_bin        | utf8mb4 |   46 | Yes     | Yes      |       1 |
| utf8mb4_general_ci | utf8mb4 |   45 |         | Yes      |       1 |
| utf8mb4_unicode_ci | utf8mb4 |  224 |         | Yes      |       1 |
+--------------------+---------+------+---------+----------+---------+
11 rows in set (0.00 sec)

tidb> select 'A'='a' collate utf8mb4_bin, 'A'='a' collate utf8mb4_general_ci, 'A'='a';
+-----------------------------+------------------------------------+---------+
| 'A'='a' collate utf8mb4_bin | 'A'='a' collate utf8mb4_general_ci | 'A'='a' |
+-----------------------------+------------------------------------+---------+
|                           0 |                                  1 |       0 |
+-----------------------------+------------------------------------+---------+
1 row in set (0.00 sec)
```
