PostgreSQL UTF-8 binary collation

后端 未结 3 881
无人共我
无人共我 2021-01-17 22:48

I would like to have a collation which orders the UTF-8 encoding of 0x1234 below of 0x1235 regardless of the character mapping in the Unicode standard. MySQL uses utf8_bin f

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 23:34

    Sort order of text depends on lc_collate (not on the system locale!). The system locale only serves as a default when creating the db cluster if you don't provide another locale.

    The behaviour you are expecting only works with locale C. Read all about it in the fine manual:

    The C and POSIX collations both specify "traditional C" behavior, in which only the ASCII letters "A" through "Z" are treated as letters, and sorting is done strictly by character code byte values.

    Emphasis mine. PostgreSQL 9.1 has a couple of new features for collation. Might be exactly what you are looking for.

提交回复
热议问题