【发布时间】:2018-06-27 13:29:37
【问题描述】:
我有两个数据相似的数据库,但我想做的是更新 sample_table from Database2 到 sample_table of Database1。
例子:
数据库1 [sample_table]
ID Reference Name
0001 Ref0001 Test1
0002 Ref0002 Test2
数据库2 [sample_table] - 有变化
ID Reference Name
0001 Ref0001 Name1
0002 Ref0002 Name2
在 Database2 的 sample_table 中,我更改了 Name 字段中的数据,我想应用 Database1 中 sample_table 中的更改。要执行什么 SQL 查询来执行此操作?我正在使用 pgAdminIII 和 pgAdmin4。 (两个数据库在同一台服务器上)
如果您有任何问题,请在下方评论。
【问题讨论】:
-
使用完全限定的表名并编写正常的更新语句?
-
Postgres 不支持跨数据库查询(或更新)。为此,您需要foreign table。
-
@a_horse_with_no_name 我已经成功完成了 PostgreSQL 的外部数据包装器的过程,但问题是我不知道将 Name 从 Database2 替换为 的查询名称 Database1.
标签: sql postgresql pgadmin