gpt4 book ai didi

sql - postgres 相当于 all_constraints

转载 作者:行者123 更新时间:2023-11-29 12:05:02 25 4
gpt4 key购买 nike

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

从 user829755 编辑:为了显示 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com