Rechercher dans le manuel MySQL
10.8.6 Examples of the Effect of Collation
Example 1: Sorting German Umlauts
Suppose that column X
in table
T
has these latin1
column
values:
Muffler
Müller
MX Systems
MySQL
Suppose also that the column values are retrieved using the following statement:
The following table shows the resulting order of the values if
we use ORDER BY
with different collations.
latin1_swedish_ci |
latin1_german1_ci |
latin1_german2_ci |
---|---|---|
Muffler | Muffler | Müller |
MX Systems | Müller | Muffler |
Müller | MX Systems | MX Systems |
MySQL | MySQL | MySQL |
The character that causes the different sort orders in this
example is the U with two dots over it
(ü
), which the Germans call
“U-umlaut.”
The first column shows the result of the
SELECT
using the Swedish/Finnish collating rule, which says that U-umlaut sorts with Y.The second column shows the result of the
SELECT
using the German DIN-1 rule, which says that U-umlaut sorts with U.The third column shows the result of the
SELECT
using the German DIN-2 rule, which says that U-umlaut sorts with UE.
Example 2: Searching for German Umlauts
Suppose that you have three tables that differ only by the character set and collation used:
Each table contains two records:
Two of the above collations have an A = Ä
equality, and one has no such equality
(latin1_german2_ci
). For that reason, you'll
get these results in comparisons:
- +------+
- | c |
- +------+
- | Bar |
- | Bär |
- +------+
- +------+
- | c |
- +------+
- | Bär |
- +------+
- +------+
- | c |
- +------+
- | Bar |
- | Bär |
- +------+
This is not a bug but rather a consequence of the sorting
properties of latin1_german1_ci
and
utf8_unicode_ci
(the sorting shown is done
according to the German DIN 5007 standard).
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-charset-collation-effect.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.