Oracle 与 Postgres 排序依据

1 oracle postgresql database-migration

我在 Oracle 和 Postgres 中运行以下查询,两者在值的排序方面显示不同的输出。

with test as (
select 'Summary-Account by User (Using Contact ID)' col1 from dual
    union all
select 'Summary-Account by User by Client by Day (Using Contact ID)' col1 from dual
)
select * from test
order by col1 desc;
Run Code Online (Sandbox Code Playgroud)

下面是甲骨文的一个

预言机输出

Postgres

with test as (
select 'Summary-Account by User (Using Contact ID)' col1
    union all
select 'Summary-Account by User by Client by Day (Using Contact ID)' col1
)
select * from test
order by col1 desc;
Run Code Online (Sandbox Code Playgroud)

PostgreSQL 输出

Oracle 排序规则是 AL32UTF8 Postgres 的 LC_CTYPS 是 en_US.UTF-8

从数据库的行为方式来看,它们看起来是相同的。如何解决这个问题?

在将查询 order by 更改为order by col1 collat​​e "C" desc;后,我在 stackoverflow 上阅读了一些关于 POSIX 和 C 的帖子;结果与 Oracle 输出匹配。

有没有办法永久应用这个?

Lau*_*lbe 6

AL32UTF8不是排序规则,而是编码(字符集)。

\n

Oracle 默认使用 \xe2\x80\x9c 二进制排序规则\xe2\x80\x9d,它对应于 PostgreSQL 中的 theCPOSIX排序规则。

\n

您有多种选择可以在 PostgreSQL 中获得类似的结果:

\n\n