Collation Issues
786
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:
SELECT X FROM T ORDER BY X COLLATE
collation_name
;
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:
mysql>
SET NAMES utf8;
mysql>
CREATE TABLE german1 (
->
c CHAR(10)
->
) CHARACTER SET latin1 COLLATE latin1_german1_ci;
mysql>
CREATE TABLE german2 (
->
c CHAR(10)
->
) CHARACTER SET latin1 COLLATE latin1_german2_ci;
mysql>
CREATE TABLE germanutf8 (
->
c CHAR(10)
->
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Each table contains two records:
mysql>
INSERT INTO german1 VALUES ('Bar'), ('Bär');
mysql>
INSERT INTO german2 VALUES ('Bar'), ('Bär');
mysql>
INSERT INTO germanutf8 VALUES ('Bar'), ('Bär');
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:
mysql>
SELECT * FROM german1 WHERE c = 'Bär';
+------+
| c |
+------+
| Bar |
| Bär |
+------+
mysql>
SELECT * FROM german2 WHERE c = 'Bär';
+------+
| c |
+------+
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...