gpt4 book ai didi

postgresql - 将连接查询从数据库复制到另一个数据表

转载 作者:行者123 更新时间:2023-11-29 13:51:24 26 4
gpt4 key购买 nike

以前,我使用 dblink 来完成任务,但它只涉及复制一个查询。如果我在一个数据库中执行连接查询(4 个表)怎么办,然后我想将数据输出复制到另一个数据库中。有人知道吗?

select 
a.sysname, a.ip, b.host_id, b.resource_name, b.resource_id
, c.metric_id, d.metric_name, c.value, c.resource_id
, to_timestamp(c.date_id)as datetime
from inv.el a
inner join inv.if b on a.host_id = b.host_id
inner join me.me_cr c on b.resource_id = c.resource_id
inner join inv.me d on c.metric_id = d.metric_id
where date_id = (
select max(date_id) from me.me_cr
)

最佳答案

你可以尝试在 Release > 9.6 上使用 postgres_fdw

... now supports remote joins...

https://www.postgresql.org/docs/9.6/static/release-9-6.html

关于postgresql - 将连接查询从数据库复制到另一个数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40672073/

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