相当于 all_constraints 的 postgres

postgres equivalent to all_constraints

oracle 提供了一个 table ALL_CONSTRAINTS 来显示定义的所有约束的详细信息。例如我可以问

select CONSTRAINT_NAME, DELETE_RULE from ALL_CONSTRAINTS where TABLE_NAME='MY_TABLE'

postgres 中有类似的东西吗?

可在 information_schema 中找到该信息。table_constraints:

select * 
from information_schema.table_constraints 
where table_name='my_table';

来自 user829755 的编辑: 为了显示 DELETE_RULE 这可以与另一个 table:

select tc.constraint_name, rc.delete_rule
from information_schema.table_constraints tc
join information_schema.referential_constraints rc using (constraint_name)
where tc.table_name = 'my_table';

我在以下页面的帮助下找到了这个,该页面展示了如何获取大量其他元数据:http://www.alberton.info/postgresql_meta_info.html