【发布时间】:2022-06-20 02:40:09
【问题描述】:
我有一个表breeds,其主键为breed_name,并且想要获取引用breeds 的所有表、列和约束的列表,而不管breeds 中引用的列如何。如果有另一个表,cats 并且具有如下约束:
CREATE TABLE cats (
cat_name text,
cat_breed text,
CONSTRAINT cat_breed_name FOREIGN KEY (cat_breed) REFERENCES breeds(breed_name))
我应该得到如下一行:
base_table base_col referencing_table referencing_col contraint_sql
breeds breed_name cats cat_breed CONSTRAINT cat_breed_name FOREIGN KEY (cat_breed) REFERENCES breeds(breed_name)
还应该列出非主键引用,并且它应该处理复合键。
【问题讨论】:
标签: sql database postgresql foreign-keys information-schema