如何确定PostgreSQL中表的排序规则?


18

我想编写一个检查在PostgreSQL中我的表上使用的排序规则的脚本,但是谷歌搜索Postgresql detect collation对于我来说不是很好,并且文档也没有使此搜索变得容易。

谁能告诉我该如何检查?

Answers:


24

要检查列上的非默认排序规则,可以使用以下查询:

select table_schema, 
       table_name, 
       column_name,
       collation_name
from information_schema.columns
where collation_name is not null
order by table_schema,
         table_name,
         ordinal_position;

编辑:要查找数据库的排序规则,需要查询`pg_database:

select datname, 
       datcollate
from pg_database;

这是手册相关部分的链接

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.