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
来源:https://stackoverflow.com/questions/9172751/postgres-show-inherited-fields