oracle 提供了一个表 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';
来自用户829755的编辑: 为了显示 DELETE_RULE,可以将其与另一个表连接:
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
关于sql - postgres 相当于 all_constraints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27945200/