Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A tutorial on proofreading set problems in MySQL

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following is to understand the MySQL proofreading set problem tutorial, I believe you will benefit a lot after reading, the text is not much in the essence, hope that the MySQL proofreading set problem tutorial this short content is what you want.

Proofreading set problem

Proofreading set is actually a way of comparing data.

There are three kinds of proofreading sets, which are:

_ bin:binary, binary comparison, case sensitive

_ cs:case sensitive, case sensitive, case sensitive

_ ci:case insensitive, case-insensitive and case-insensitive.

View (all) proofreading sets-> basic syntax: show collation

As shown in the figure above, the MySQL database supports more than 100 proofing sets.

Next, let's take a look at the application of proofreading sets, because proofreading sets take effect only when the data are compared. Here, we use utf8's _ bin and _ ci proofing sets to compare:

-- create two tables create table my_collate_bin (name char (10)) charset utf8 collate utf8_bin;create table my_collate_ci (name char (10)) charset utf8 collate utf8_general_ci with different proofing sets

As shown in the figure above, we created two tables, my_collate_bin and my_collate_ci, with proofsets of _ bin and _ ci. Then, add data to the two tables:

-add data insert into my_collate_bin values ('a'), ('A'), ('B'), ('b'); insert into my_collate_ci values ('a'), ('A'), ('B'), ('b') to the table

Then look at the data in the two tables:

-- View the data in the table select * from my_collate_bin;select * from my_collate_ci

Next, we sort by a field in the table (where both my_collate_bin and my_collate_ci have only one field), the basic syntax is:

Order by + field name + [asc/desc]

Where asc represents ascending order, desc represents descending order, and defaults to ascending order. Execute the following SQL statement:

-- sort and compare select * from my_collate_bin order by name;select * from my_collate_ci order by name

As shown in the picture above, it is obvious that the proofreading set has taken effect!

In addition, we need to pay special attention to the fact that the proofreading set must be declared before there is no data, and if the proofreading set is modified after the data is available, the modification is invalid.

Warm reminder: the content enclosed in the symbol [] indicates optional; the symbol + indicates the meaning of connection

After reading the MySQL proofreading collection tutorial, many readers will want to know more about it. If you need more industry information, you can follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report