这是我的父表: TableA
+-----+-----------+
+ id + name +
+-----+-----------+以下是继承tableA: TableB TableC的表
+-----+-----------+----------+
+ id + date + year +
+-----+-----------+----------+
+-----+-----------+----------+
+ id + owner + age +
+-----+-----------+----------+我有一个从TableA中的名称获得id的Select,我需要的是获取包含该特定id的表的名称。我想去看看,但我是个懒人,我不知道怎么做。
谢谢。
发布于 2019-03-20 09:14:06
为此,您可以使用系统列 tableoid。
以下示例:
create table table_a (id integer, name text);
create table table_b () inherits (table_a);
create table table_c () inherits (table_a);
insert into table_b values (1, 'one');
insert into table_c values (2, 'two');
select tableoid::regclass as table_name, id, name
from table_a;返回:
table_name | id | name
-----------+----+-----
table_b | 1 | one
table_c | 2 | two https://stackoverflow.com/questions/55257066
复制相似问题