Postgres:显示继承的字段 [英] Postgres: show inherited fields
本文介绍了Postgres:显示继承的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该实现哪种查询来获取被继承的列?阅读了此综合性帖子后,找不到解决方法。
What query should I implement to get columns that are inherited? Having read this comprehensive post didn't find the solution.
推荐答案
如果我正确理解,您想知道作为表之间继承的一部分的列的名称。
If I understand correctly, you want to know the names of the columns that are part of an inheritance between tables.
SELECT nmsp_parent.nspname AS parent_schema,
parent.relname AS parent_table,
nmsp_child.nspname AS child_schema,
child.relname AS child_table,
column_parent.attname AS column_parent_name
FROM pg_inherits
JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
JOIN pg_class child ON pg_inherits.inhrelid = child.oid
JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
JOIN pg_attribute column_parent ON column_parent.attrelid = parent.oid
WHERE column_parent.attnum > 0
AND column_parent.attname NOT ILIKE '%pg.dropped%';
此查询显示作为层次结构一部分的列名称。希望您能为您服务
This query displays the column name that is part of a hierarchy. I hope you serve
这篇关于Postgres:显示继承的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文