在 Postgres 中对表执行 a\d+
时,它会列出表模式以及索引,以及将其作为 FK 引用的其他表。例子:
Table "public.foo_table"
Column | Type | Modifiers | Storage | Description
------------+------+---------------+----------+-------------
id | text | | extended |
foo | text | | extended |
bar | text | | extended |
Indexes:
"foo_table_id_idx" btree (id)
"foo_table_foobar_idx" btree (foo,bar)
Foreign-key constraints:
"foo_table_bar_fk" FOREIGN KEY (bar) REFERENCES public.bar_table(id)
Referenced by:
TABLE "public.bar_table" CONSTRAINT "bar_table_foo_fk" FOREIGN KEY (foo) REFERENCES public.foo_table(foo)
Has OIDs: no
您可以做一些事情$dbh->statistics_info(...)
来检索索引信息。是否有类似的东西来检索 FK 信息(引用和引用)?
看来我的下一个选择是发出->do()
命令或查询系统表。