Sql 相当于所有约束的postgres

Sql 相当于所有约束的postgres,sql,oracle,postgresql,Sql,Oracle,Postgresql,oracle提供了一个表ALL_CONSTRAINTS,其中显示了定义的所有约束的详细信息。例如,我可以问 select CONSTRAINT_NAME, DELETE_RULE from ALL_CONSTRAINTS where TABLE_NAME='MY_TABLE' postgres中是否有类似的内容?表中提供了相关信息: select * from information_schema.table_constraints where table_name='my_table';

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

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

postgres中是否有类似的内容?

表中提供了相关信息:

select * 
from information_schema.table_constraints 
where table_name='my_table';
从用户829755编辑: 为了显示DELETE_规则,可以将其与另一个表联接:

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';

我在下面一页的帮助下发现了这一点,该页展示了如何获取大量其他元数据:

,谢谢,效果很好。只是它不包含删除规则,但它让我看到了一个有趣的页面,显示了完整的答案,所以我根据好的观点扩展了你的答案!我本应该更深入地挖掘以匹配您的特定查询,但是,正如您所发现的,在information_schema中的视图和它们所基于的pg_catalog中的表之间,您可以访问任何您需要了解的内容。