0

I try to migrate to postgres from pervasive. In pervasive there was something like 'upper.alt' - alternative collation. I don't really know how it works, but I have to make my new postgres database to behave like pervasive with this collation.

I use Postgres 9.2.4 and utf-8 encoding and LC_COLLATE='Polish_Poland.1250' .

4

1 回答 1

1

您可以尝试使用 COLLATE "C" 进行订购。这将在您的示例中得到您想要的。虽然有副作用!实际上,所有内容都是根据编码字符的字节值排序的。

WITH x(col) AS (
    VALUES
     ('ABC_AAAAA')
    ,('ABC_BBBBB')
    ,('ABC_ZZZZZ')
    ,('ABCAAAAA')
    ,('ABCBBBBB')
    ,('ABCZZZZZ')
    )
SELECT *
FROM   x
ORDER  BY col COLLATE "C"

Postgres 9.1 引入了此选项来更改单个表达式的排序规则(而不是使用在创建 db 时定义的排序规则)。
更多关于手册中的整理在这里

于 2013-06-17T22:34:41.527 回答