我需要获取最接近特定于语言环境的字符,该字符大于(在字符串比较方面)postgresql 中给定的字符。我试着用
SELECT chr(ascii(x)+1);
但是当我测试它的时候,它有时不能按照我想要的方式工作,因为
SELECT chr(ascii('я')+1);
返回 ѐ,但是
SELECT 'я' < 'ѐ';
返回假。
最佳答案
文本的排序顺序取决于 lc_collate
,而不是 ASCII 码或 Unicode 代码点。
在大多数语言环境中,这些恰好与基本 ASCII 字符齐头并进。其余的可能会有所不同。
show lc_collate
的输出是什么?
您期望的行为仅适用于区域设置 C
。阅读所有相关信息 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.
强调我的。 PostgreSQL 9.1 有几个新的整理功能。
关于postgresql - 如何在postgresql中获得比给定字符大的最接近字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7723752/