http://dev.mysql.com/doc/refman/5.0/en/charset.html
結論:
1. Character Sets(字元集) and Collations(校對):
Character Sets: a set of symbols and encodings
example:
A => 0
B => 1
C => 2
Collations: Given a character set, a set of rules for comparing characters in a character set. That is, given a character set, how are you going to compare two strings?
example:
Suppose that we want to compare two string values, "A" and "B".
The simplest way to do this is to look at the encodings: 0 for "A" and 1 for "B". Because 0 is less than 1, we say "A" is less than "B". What we've just done is apply a collation to our character set.
(註:Collations是根據encodings做判斷,而不是以symbols做為判斷)
(註:Any given character set always has at least one collation.)
2.
每一個connection有自己的Character Sets和Collations,詳情請看:
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
此外,There are default settings for character sets and collations at four levels: server, database, table, and column. (由上層到下層)
如果創建下層的時候完全沒有指定Character Set and Collation,該層就會沿用上層的Character Set and Collation。例如你在CREATE TABLE的時候完全沒有設定Character Set and Collation的話,該TABLE就會沿用database的Character Set and Collation。
但是如果你在CREATE TABLE的時候只設定character set,那麼MySQL就會幫你把該TABLE的collation設定為該character set的default collation。如果只有指定TABLE的collation,那麼該TABLE的character set就會被設定為該collation對應的character set。
沒有留言:
張貼留言