MySQL character set and proofing rules

Source: Internet
Author: User

Encoding: Computers are binary storage, so the display symbols need to be converted to binary numbers to be stored, and each character is converted into a binary number, which is the character encoding.

Character Set

Characters are used to display abstract symbols. a character set is a set of characters and character encodings.

Common character-set encodings:
ASCII character set, GB2312 character set, GBK character set, latin1 character set, Unicode character set, etc.

show character set;You can get all the character sets supported by MySQL.

Modifying the database character set
alter database liguodong character set utf8;

MySQL can use multiple character sets to save data.
MySQL can set the character set for fields, tables, databases, servers, and also set the connection character set (when the client interacts with the server side).

meaning of the encoding related variables:

You can character-set-server=utf8 modify the encoding settings for the server in My.ini:

Server Character Set:

Connection Character Set:

Proofing Rules:

Each set of coded character sets has a collation rule associated with it. Proofing rules Refer to the comparison between characters within the current character set.
Each character set provides one or more proofing rules.
The usual naming conventions are:字符集_语言名_ci|cs|bin

Common CI is case insensitive. CS is case-sensitive and bin bytes are compared.

To view the proofing rules directives:

show collation;show collation like ‘gbk%‘;

When setting the character set, you can set the proofing rules that are used by the current character set. However, no proofing rules are set, so each character set has a default proofing rule.

Take GBK as an example to compare the differences between chinese_ci,bin

create table tab3(name varchar(10)) character set gbk collate gbk_chinese_ci;create table tab4(name varchar(10)) character set gbk collate gbk_bin;

The default is Gbk_chinese_ci, so the character set is not displayed.

show create table tab3\Gshow create table tab4\G


 Insert  into tab3 values(' a '); Insert  into tab3 values(' B '); Insert  into tab3 values(' C '); Insert  into TAB4 values(' a '); Insert  into TAB4 values(' B '); Insert  into TAB4 values(' C ');

Affects the preservation of data, character sets.
Comparison of image data, proofing set.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL Character set and proofing rules

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.