区分大小写的排序(词法排序)不工作 PostgreSQL citext 类型
Case sensitive sorting (lexical sorting) not working PostgreSQL citext type
我想在 PostgreSQL 中对 citext
类型同时执行搜索和排序。
select name from employee ORDER BY name ASC;
对于上述查询,我得到以下排序顺序:
"Adam"
"balaji"
"Cartus"
"dalal"
"erfan"
"Eric"
"Focus"
"lucus"
有什么方法可以按以下顺序排序:
"Adam"
"Cartus"
"Eric"
"Focus"
"balaji"
"dalal"
"erfan"
"lucus"
我使用的是 postgres 版本 "PostgreSQL 9.4.10, compiled by Visual C++ build 1800, 64-bit"。
你可以使用
ORDER BY name::text COLLATE "POSIX"
这会将 name
转换为区分大小写的类型并使用二进制排序规则。
我想在 PostgreSQL 中对 citext
类型同时执行搜索和排序。
select name from employee ORDER BY name ASC;
对于上述查询,我得到以下排序顺序:
"Adam"
"balaji"
"Cartus"
"dalal"
"erfan"
"Eric"
"Focus"
"lucus"
有什么方法可以按以下顺序排序:
"Adam"
"Cartus"
"Eric"
"Focus"
"balaji"
"dalal"
"erfan"
"lucus"
我使用的是 postgres 版本 "PostgreSQL 9.4.10, compiled by Visual C++ build 1800, 64-bit"。
你可以使用
ORDER BY name::text COLLATE "POSIX"
这会将 name
转换为区分大小写的类型并使用二进制排序规则。