I need to select data from a table and sort it with an ORDER BY clause. The problem is that the column contains text data with Czech diacritics. I cannot use COLLATE because the database is part of the postgres cluster that was created using lc_collate = en_US.UTF-8, and I cannot allow the downtime caused by reconstructing the cluster with the correct lc_collate.
Sample data:
CREATE TABLE test ( id serial PRIMARY key, name text ); INSERT INTO test (name) VALUES ('Žoo'), ('Zoo'), ('ŽOO'), ('ZOO'), ('ŽoA'), ('ŽóA'), ('ŽoÁ'), ('ŽóÁ');
Ideal yield:
SELECT * FROM test ORDER BY name COLLATE "cs_CZ.utf8"; id | name
Here I found my solution:
SELECT * FROM test ORDER BY name USING ~<~; id | name
The result is close enough (for my use) - carboxylic letters AFTER without caroling.
My slightly non -ect analogue of Postgresql with the operator ~<~
edit : turned into a new question .
Returning to the question : is there any other solution to get the perfect order, except to recreate the postgres cluster with the correct locale?
It would also be nice to bind ~<~
to the operator.
source share