Get the App
SLTechnology News&Howtos  ›  Database  › 

Character set and sorting rules of Database built by mysql

Shulou Source: shulou.com Published: 2022-06-01 22:37:13 11月02日 Update

1. Character set description:

Generally choose utf8. Here's the difference between utf8 and utfmb4.

Utf8mb4 is compatible with utf8 and can represent more characters than utf8.

The unicode coding area belongs to the traditional utf8 area from 1 to 126. of course, utf8mb4 is also compatible with this area. below 126 lines is the utf8mb4 extension area. When you need to store those characters, you use utf8mb4, otherwise it's just a waste of space.

two。 Sorting rules

There are generally two kinds of sorting: utf_bin and utf_general_ci

Bin is binary, so an and A will be treated differently.

For example, you run:

SELECT * FROM table WHERE txt ='a'

Then you can't find the line txt ='A'in utf8_bin, but utf8_general_ci can.

Utf8_general_ci is case-insensitive, which you need to use when registering a user name and email.

Utf8_general_cs is case-sensitive. If you use this for your user name and mailbox, it will lead to adverse consequences.

Utf8_bin: string each string is compiled and stored with binary data. Case-sensitive and can store binary content

There is no real difference between utf8_unicode_ci and utf8_general_ci in Chinese and English.

The proofreading speed of utf8_general_ci is fast, but the accuracy is slightly lower. (the accuracy is enough, generally choose this to build the database)

The accuracy of utf8_unicode_ci is high, but the proofreading speed is slow.

Tags: Character binary accuracy size sort string time proofreading user user name speed mailbox storage selection character set data rules bad one line traditional Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple vpn Linux Shulou Technology