postgresql - 如何在postgresql中获得比给定字符大的最接近字符?

标签 postgresql character-encoding locale string-comparison

我需要获取最接近特定于语言环境的字符,该字符大于(在字符串比较方面)postgresql 中给定的字符。我试着用

SELECT chr(ascii(x)+1);

但是当我测试它的时候,它有时不能按照我想要的方式工作,因为

SELECT chr(ascii('я')+1);

返回 ѐ,但是

SELECT 'я' < 'ѐ';

返回假。

最佳答案

文本的排序顺序取决于 lc_collat​​e,而不是 ASCII 码或 Unicode 代码点。 在大多数语言环境中,这些恰好与基本 ASCII 字符齐头并进。其余的可能会有所不同。

show lc_collat​​e 的输出是什么?

您期望的行为仅适用于区域设置 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/

相关文章:

locale - 人行道 : can't set the locale; make sure $LC_* and $LANG are correct

java - 错误: operator does not exist: character varying = bytea

character-encoding - 数据 URI 默认字符集

sql - 是否有一个函数可以让我输出 json 数组中元素的当前索引?

character-encoding - 如何在 .Net XDocument 中保留字符实体?

c++ - 该程序是否在所有标准系统上显示四套牌(♠♣♥♦)?

regex - bash 运算符 =~ 是否尊重语言环境?

c++ - 如何更改 VS2008 中的构建语言?

json - 任何人都可以帮助为下面的链接修改光标

ruby-on-rails - rails/PostgreSQL : How can I quickly group records using a datetime field by date in a specific time zone?