Postgres反向继承? (从父 table 继承行)

Postgres reverse inheritance? (inherit rows from parent table)

我有一些所有模式共有的记录。我将这些记录放在一个共享模式 table 中,并希望在每个子模式中从这个共享父 table 继承记录行。

假设我有以下模式:

CREATE SCHEMA parent; 
CREATE SCHEMA a;
CREATE SCHEMA b;

CREATE TABLE parent.component (product_id serial PRIMARY KEY, title text);
CREATE TABLE a.component () INHERITS (parent.component); 
CREATE TABLE b.product () INHERITS (parent.component); 

INSERT INTO parent.component(title) VALUES ('parent'); 
INSERT INTO a.component(title) VALUES ('a_test') ,('a_test2') ;
INSERT INTO b.component(title) VALUES ('b_test') ,('b_test2');

有没有办法 select 当我在 parenta.componentb.component 中发出 select 的行并集时ab ?

例如:

SELECT * FROM a.component; 

returns 行:

id   |   title
---------------
1        parent
2        a_test
3        a_test2

PostgreSQL 有多重继承,所以一个 table 可以是许多 table 的 child。你可以试试反方向继承!

但也许简单的 UNION ALL 查询是更简单更好的解决方案。