Posts

Showing posts from August, 2023

Mysql CharacterSet and Collation

Image
Character set is a set of symbols and encodings, whereas collation is a set of rules for comparing characters in a character set. Let’s understand the concept with an example:- Suppose we have an alphabet with 4 letters: A,B,a,b. We give each letter a number: A=0, B=1, a=2, b=3. The letter A is a symbol, 0 is the encoding for A. The combination of all 4 letters and their encodings is a character set. Suppose we want to compare two string values A and B, the simplest way to do so is using encodings: 0 for A and 1 for B. As 0 is less than 1, we say A is less than B. Here, we’ve just applied a collation to our character set. Hence, collation is a set of rules (only one rule here, to compare the encodings). There may be different types of collations available like:- ci/cs: (case insensitive/ case sensitive) : it has a separate rule in case of case insensitivity, i.e. upper and lower case are the same. ai/as: (accent sensitive/accent insensitive): many of character sets may not just have al...