小编Arn*_*ier的帖子

Postgresql 12 - 排序规则在 Windows / Linux 上不起作用

我已经在 Wnindows 和 Linux CentOS 8 上安装了 Postgresql 12。

对于我的项目,我需要创建自己的 ICU 排序规则并将其应用于所有字符列(在列创建中或按请求排序 = 首选)。

在此之前,我尝试制作一个简单的测试用例来检查它是否按预期工作......但事实并非如此。

包含一些数字和字母数据的简单表格

DROP TABLE IF EXISTS TBL;
CREATE TABLE TBL ( TEXT1 CHARACTER(5), TEXT2 CHARACTER(5) );
INSERT INTO TBL VALUES
 ('aaaaa', 'aaaaa')
,('aaaaa', '00000')
,('aaaaa', 'bbbbb')
,('aaaaa', '11111')

,('bbbbb', '22222')
,('00000', '22222')
,('ccccc', '22222')
,('11111', '22222');
Run Code Online (Sandbox Code Playgroud)

官方文档中拉丁字符后的数字排序规则 https://www.postgresql.org/docs/12/collat​​ion.html

CREATE COLLATION digitslast (provider = icu, locale = 'en-u-kr-latn-digit');
CREATE COLLATION digitslast (provider = icu, locale = 'en@colReorder=latn-digit');
    Sort digits after Latin letters. (The default is digits before …
Run Code Online (Sandbox Code Playgroud)

postgresql collation icu postgresql-12

5
推荐指数
1
解决办法
770
查看次数

标签 统计

collation ×1

icu ×1

postgresql ×1

postgresql-12 ×1