Subject | How to create properly a custom accent sensitive collation order? |
---|---|
Author | Gabor Boros |
Post date | 2017-12-08T16:00:11Z |
Hi All,
I have a database with default UTF8 character set and UNICODE_CI collation:
CREATE DATABASE 'MYDB' PAGE_SIZE 4096 DEFAULT CHARACTER SET UTF8
COLLATION UNICODE_CI;
Execute the next script:
CREATE COLLATION UNICODE_CI_AS_HU FOR UTF8 FROM UNICODE_CI ACCENT
SENSITIVE 'LOCALE=hu_HU';
ALTER CHARACTER SET UTF8 SET DEFAULT COLLATION UNICODE_CI_AS_HU;
CREATE TABLE TABLE_1 (NAME VARCHAR(60));
INSERT INTO TABLE_1 VALUES ('Vál');
INSERT INTO TABLE_1 VALUES ('Val');
INSERT INTO TABLE_1 VALUES ('Vak');
INSERT INTO TABLE_1 VALUES ('Vac');
INSERT INTO TABLE_1 VALUES ('Vab');
INSERT INTO TABLE_1 VALUES ('Váb');
After that I want to get the ordered result:
SELECT NAME FROM TABLE_1 ORDER BY NAME
or
SELECT NAME FROM TABLE_1 ORDER BY NAME COLLATE UNICODE_CI_AS_HU
give the next result:
Vab
Váb
Vac
Vak
Val
Vál
but the expected is:
Vab
Vac
Vak
Val
Váb
Vál
What I am doing wrong?
Gabor
I have a database with default UTF8 character set and UNICODE_CI collation:
CREATE DATABASE 'MYDB' PAGE_SIZE 4096 DEFAULT CHARACTER SET UTF8
COLLATION UNICODE_CI;
Execute the next script:
CREATE COLLATION UNICODE_CI_AS_HU FOR UTF8 FROM UNICODE_CI ACCENT
SENSITIVE 'LOCALE=hu_HU';
ALTER CHARACTER SET UTF8 SET DEFAULT COLLATION UNICODE_CI_AS_HU;
CREATE TABLE TABLE_1 (NAME VARCHAR(60));
INSERT INTO TABLE_1 VALUES ('Vál');
INSERT INTO TABLE_1 VALUES ('Val');
INSERT INTO TABLE_1 VALUES ('Vak');
INSERT INTO TABLE_1 VALUES ('Vac');
INSERT INTO TABLE_1 VALUES ('Vab');
INSERT INTO TABLE_1 VALUES ('Váb');
After that I want to get the ordered result:
SELECT NAME FROM TABLE_1 ORDER BY NAME
or
SELECT NAME FROM TABLE_1 ORDER BY NAME COLLATE UNICODE_CI_AS_HU
give the next result:
Vab
Váb
Vac
Vak
Val
Vál
but the expected is:
Vab
Vac
Vak
Val
Váb
Vál
What I am doing wrong?
Gabor