Changes between Version 1 and Version 2 of Ticket #9682, comment 15


Ignore:
Timestamp:
Sep 20, 2015, 6:02:52 PM (9 years ago)
Author:
Craig Ringer

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9682, comment 15

    v1 v2  
    11Readers 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.
    22
    3 `SELECT * FROM collate_demo WHERE test_col > 'A' COLLATE "C" ORDER BY test_col COLLATE "C";`
     3{{{
     4SELECT * FROM collate_demo WHERE test_col > 'A' COLLATE "C" ORDER BY test_col COLLATE "C";
     5}}}
    46
    57to use POSIX  byte-order based collation.
     
    1921I ''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.
    2022
     23Users can work around this in the mean time by `ALTER`ing their columns to give them a `COLLATE` clause. e.g.
     24
     25{{{
     26ALTER TABLE collate_demo ALTER COLUMN test_col TYPE text COLLATE "C";
     27}}}
     28
     29Keep the existing type, of course. Note that this might re-create indexes, which could take a while and hold an exclusive lock.
     30
     31There'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
    2133''(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)''.
Back to Top