【问题标题】:Copy join-query from database to another datable将连接查询从数据库复制到另一个数据表
【发布时间】:2017-04-02 00:13:00
【问题描述】:

以前,我使用 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
)

【问题讨论】:

    标签: postgresql inner-join dblink


    【解决方案1】:

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

    ...现在支持远程连接...

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-07
      • 2020-01-13
      相关资源
      最近更新 更多