I Understand Character sets but I don’t understand Collation. I know you get a default collation with every Character set in Mysql or any RDBMS but I still don’t get it! Can someone please explain in layman terms?
Thank you in advance 😉
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main point of a database collation is determining how data is sorted and compared.
Case sensitivity of string comparisons
will return true for a case insensitive collation; false for a case sensitive one.
Which collation does which can be told by the
_ciand_cssuffix in the collation’s name._bincollations do binary comparisons (strings must be 100% identical).Comparison of umlauts/accented characters
the collation also determines whether accented characters are treated as their latin base counterparts in string comparisons.
will return true in the former case; false in the latter. You will need to read each collation’s description to find out which is which.
String sorting
The collation influences the way strings are sorted.
For example,
Umlauts
Ä Ö Üare at the end of the alphabet in the finnish/swedish alphabetlatin1_swedish_cithey are treated as
A O Uin German DIN-1 sorting (latin_german1_ci)and as
AE OE UEin German DIN-2 sorting (latin_german2_ci). (“phone book” sorting)In
latin1_spanish_ci, “ñ” (n-tilde) is a separate letter between “n” and “o”.These rules will result in different sort orders when non-latin characters are used.
Using collations at runtime
You have to choose a collation for your table and columns, but if you don’t mind the performance hit, you can force database operations into a certain collation at runtime using the
COLLATEkeyword.This will sort
tableby thenamecolumn using German DIN-2 sorting rules:Using
COLLATEat runtime will have performance implications, as each column has to be converted during the query. So think twice before applying this do large data sets.MySQL Reference: