Changes between Version 1 and Version 2 of Ticket #9682, comment 15
- Timestamp:
- Sep 20, 2015, 6:02:52 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #9682, comment 15
v1 v2 1 1 Readers should note that `COLLATE` is SQL-standard, though unfortunately the collation ''names'' are not. You will be able to use a solution that implements the `COLLATE` clause in PostgreSQL too, e.g. 2 2 3 `SELECT * FROM collate_demo WHERE test_col > 'A' COLLATE "C" ORDER BY test_col COLLATE "C";` 3 {{{ 4 SELECT * FROM collate_demo WHERE test_col > 'A' COLLATE "C" ORDER BY test_col COLLATE "C"; 5 }}} 4 6 5 7 to use POSIX byte-order based collation. … … 19 21 I ''strongly'' recommend a solution using the `COLLATE` clause, but keep in mind that it's not a global query modifier. It affects the operator or `ORDER BY` clause it's attached to, not the whole query. 20 22 23 Users can work around this in the mean time by `ALTER`ing their columns to give them a `COLLATE` clause. e.g. 24 25 {{{ 26 ALTER TABLE collate_demo ALTER COLUMN test_col TYPE text COLLATE "C"; 27 }}} 28 29 Keep the existing type, of course. Note that this might re-create indexes, which could take a while and hold an exclusive lock. 30 31 There's probably a way to do this via Django's DDL support at `CREATE TABLE` time or via a schema migration, but I'll leave that to people who know Django. 32 21 33 ''(I don't use Django, I contribute to PostgreSQL and I'm here because of some research I was doing for a Stack Overflow user who runs Django on Pg)''.