Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgres:显示继承的字段_Postgresql_Metadata_Inherited - Fatal编程技术网

Postgresql Postgres:显示继承的字段

Postgresql Postgres:显示继承的字段,postgresql,metadata,inherited,Postgresql,Metadata,Inherited,我应该实现什么查询来获取继承的列?阅读了综合文章后,没有找到解决方案。如果我理解正确,您想知道作为表间继承一部分的列的名称 SELECT nmsp_parent.nspname AS parent_schema, parent.relname AS parent_table, nmsp_child.nspname AS child_schema, child.relname AS child_table,

我应该实现什么查询来获取继承的列?阅读了综合文章后,没有找到解决方案。

如果我理解正确,您想知道作为表间继承一部分的列的名称

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%';
此查询显示作为层次结构一部分的列名。我希望你能为我服务