sql - postgres 相当于 all_constraints

标签 sql oracle postgresql

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/

相关文章:

c# - LINQ 连接具有不同数据类型的多个列

postgresql - 使用存储过程 PostgreSQL 11.1 从表中检索数据

ruby-on-rails - 表条目在开发中工作正常但在生产中不工作

sql - 在 Oracle 中创建前导零

c# - .NET Oracle 管理的数据访问连接池不工作或速度慢

postgresql WAL 文件内部结构

sql - PySpark 数据透视作为 SQL 查询

mysql - 使用连接根据范围内的日期匹配表行

php - 对连接表有限制吗?

asp.net - Oracle 和 asp.net