first, what is a character set :
To put it simply, a character set is a set of corresponding relationships;
1, the current computer is built on the basis of binary system, binary is a numerical expression, that is, binary only expression "number", such as the decimal 3, in the binary
Can be written as 00000011;
2, however, in the real life compared to the "number" we use more is the "text"; then how to solve this problem (how to save the text)? But the question is not
They, they decided to settle in a compromise way, for example: Save ' a ' when I save a 0, save ' B ' When I save a 1, save ' a ' when I save a 2
Save ' B ' when I save a 3. So the whole correspondence becomes this.
Character---encoding
' A '-0
' B '--1
' A '-2
' B '--3
In this way we define a character set of only 4 characters, but we do not know where the low is in the character set compared to Gbk\utf8.
second, what is the collation :
1, the above content we have already defined a character set, with the character set some of the most basic operations may have done, such as: I want to know a character it is not ' a ' then
I just have to see if this character's code is 0, so it turns a character problem into a number problem, so the data equals (=), size (>,<), there is
A new meaning.
2. Do we have any shortage of this character set? such as: To do not distinguish between the case, then our previous =,<,> have come to spirit, we will also give this character set to add a new
Rules, as we can be rude here with the rule 1:0=2, 2:1=3, so it is possible to do a case-insensitive.
How can I specify a character set in MySQL :
1. mysql can specify the default character set at the instance level, the configuration item name: Character_set_server
2. You can specify a character set when creating a library
Create Database character set UTF8;
3. You can specify the table-level character set when creating a table
Create Table int not NULL Primary Key varchar (4characterset UTF8; -- specifies that the character set is UTF8 at the table level
4. You can specify when creating a table
Create Table int not NULL Primary Key varchar (4characterset UTF8); -- specifies that the character set of the name column is UTF8
----
MySQL Character set explanation