Home > Database > Mysql Tutorial > Introduction to MySQL character sets and collation order

Introduction to MySQL character sets and collation order

巴扎黑
Release: 2017-05-19 15:14:54
Original
1940 people have browsed it

Character set and proofreading order

Character set is a method for people to map natural text to computer representation. It is a collection of some text and characters. Common ones include GBK (upgraded version of GB2312 character set), BIG5 character set, GB18030 character set, UTF-8 (upgraded version of Unicode character set), and collation rules are some rules specified in the character set (such as which characters are case-sensitive and which characters are not case-sensitive,
Open cmd and run after entering MYSQL

show character set
Copy after login


to check which character sets the server supports;

show collation
Copy after login


Character collation rules, if not Specify the corresponding character set collation rules, and the default mode will be used for collation and sorting;

show variables like "%character%";
Copy after login


View the system character set setting variables;

set names utf8
Copy after login


Sets the character set used for client and server connections;

Database tables are used to store and retrieve data. Different languages ​​and character sets require different ways of storing and retrieving data. Therefore, MySQL requires. Accommodating different character sets (different letters and characters), adapting to different methods of sorting and retrieving data

When discussing multiple languages ​​and character sets, you will encounter the following important terms:

1. Character set is a collection of letters and symbols;

2. Encoding is the internal representation of a certain character set member;

3. Proofreading is an instruction that specifies how characters are compared.

Why is it important to sort English text? Maybe not. Are the words APE, apex and Apple in the correct sorting order? It depends on whether you want to use case sensitivity. Written collation order, these words have one way of sorting, using case-insensitive collation has another way of sorting. This not only affects sorting (such as sorting data with ORDER BY), but also affects searching (for example, looking for WHERE of apple). clause can find APPLE). The situation is more complicated when using characters such as French à or German ö, and when using character sets that are not based on Latin (Japanese, Hebrew, Russian, etc.) More complicated.

In normal MySQL database activities (SELECT, INSERT, etc.), there is not much to worry about. The decision about which character set and collation to use is made at the server, database and table levels.

[Related recommendations]

1. mysql free video tutorial

2. MySQL transaction-use retention points, change the default commit Detailed explanation of behavior

3. MySQL transaction-ROLLBACK, detailed explanation of COMMIT usage

4. Explanation of MySQL transaction processing examples

5. MySQL UPDATE trigger (update) and trigger in-depth analysis

The above is the detailed content of Introduction to MySQL character sets and collation order. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template