Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use collation and Character set of mysql

Shulou Source: shulou.com Published: 2022-05-31 13:59:11 11月02日 Update

This article introduces the knowledge of "how to use collation and Character set of mysql". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Collation and Character set

The collation of mysql roughly means character order. First of all, the character is regardless of size, so for the character >, =

< 操作就需要有个字符序的规则。collation做的就是这个事情,你可以对表进行字符序的设置,也可以单独对某个字段进行字符序的设置。 mysql的字符序遵从命名惯例。以_ci(表示大小写不敏感),以_cs(表示大小写敏感),以_bin(表示用编码值进行比较)。(ci 是 case insensitive 的缩写, cs 是 case sensitive 的缩写)。 collation 名字的规则可以归纳为这两类: 1. __ 2. _bin 查询character set 与 collation的对应关系: mysql>

Show collation

1. When the character set of the table is latin1, if the field type is nvarchar, the character set of the field automatically changes to utf8. It can be seen that database character set, table character set and field character set can be covered step by step.

two。 How to distinguish case in comparison under the collation of ci

Method 1:

Mysql > select * from pet where binary name = 'Histler'

Method two

Mysql > select * from pet where name = binary 'Histler'

It is recommended to use method 2, which ensures that the index of the current field is still valid, and the method will invalidate the index.

This is the end of "how to use mysql's collation and Character set". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Characters sizes fields methods content that is more knowledge indexes abbreviations rules practical effective successful learning next things usage names dilemmas character sets Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Docker OPPO Reno Microsoft