Implement Vietnamese Collation in MySQL

MySQL has yet to integrate support for Vietnamese Collation (Bug #4745). You can, in the meantime, add the missing collation simply by replacing the Index.xml file in <MySQL Server 5.x>\share\charsets directory with this Index.xml, which implements the Vietnamese collation for both utf8 and ucs2 charsets. As a result, you will have native support for both sort and compare operations in MySQL 5.x Community Server. (Be sure to restart the database server for it to read in the new collations.)

Using MySQL Administrator or Query Browser tool, you can set the Charset and Collation for Table and Columns when you get to MySQL Table Editor dialog. With the modified Index.xml installed, you can see the new Vietnamese Collations after selecting either utf8 or usc2 for Charset.

With the new collations, you can run the query as follows, assuming your table has a column with one character of the Vietnamese alphabetical set in each row:

SELECT letter FROM letters WHERE letter='a' COLLATE utf8_vietnamese1_ci;
would return 'a', 'à', 'ả', 'ã', 'á', 'ạ', and their capitals, not necessarily in any order. The same result would also be returned for any diacritical variation of the character 'a' in the WHERE clause.

On the other hand, the query

SELECT letter FROM letters WHERE letter='a' COLLATE utf8_vietnamese2_ci;
would return only 'a' and 'A'.

To put the result set in Vietnamese alphabetical order, add the ORDER BY clause with appropriate collation:

SELECT letter FROM letters WHERE letter='a' COLLATE utf8_vietnamese1_ci ORDER BY letter COLLATE utf8_vietnamese2_ci;