gpt4 book ai didi

sql - 从父表中选择一行时显示子表名称

转载 作者:行者123 更新时间:2023-11-29 14:19:42 24 4
gpt4 key购买 nike

我有一个带有 4 个子表的继承表。
如何知道特定行的源表?

最佳答案

来自 PostgreSQL documentation on inheritance :

By doing a join with pg_class you can see the actual table names:

SELECT p.relname, c.name, c.altitude
FROM cities c, pg_class p
WHERE c.altitude > 500 AND c.tableoid = p.oid;

在上面的示例中,p.relname 将返回从中获取行的特定子表。

关于sql - 从父表中选择一行时显示子表名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33585211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com