加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 从两个独立的数据库加入结果

发布时间:2020-12-13 16:43:27 所属栏目:百科 来源:网络整理
导读:是否可以从两个单独的postgres数据库中加入行? 我在一个服务器与夫妇数据库的系统工作,有时我真的需要这样的功能。 根据 http://wiki.postgresql.org/wiki/FAQ There is no way to query a database other than the current one. Because PostgreSQL loads
是否可以从两个单独的postgres数据库中加入行?

我在一个服务器与夫妇数据库的系统工作,有时我真的需要这样的功能。

根据 http://wiki.postgresql.org/wiki/FAQ

There is no way to query a database other than the current one.
Because PostgreSQL loads database-specific system catalogs,it is
uncertain how a cross-database query should even behave.
contrib/dblink allows cross-database queries using function calls. Of
course,a client can also make simultaneous connections to different
databases and merge the results on the client side.

编辑:3年后(2014年3月),此常见问题条目已修订,更有帮助:

How do I perform queries using multiple databases?

There is no way to directly query a database other than the current
one. Because PostgreSQL loads database-specific system catalogs,it is
uncertain how a cross-database query should even behave.

The SQL/MED support in PostgreSQL allows a “foreign data wrapper” to
be created,linking tables in a remote database to the local database.
The remote database might be another database on the same PostgreSQL
instance,or a database half way around the world,it doesn’t matter.
postgres_fdw is built-in to PostgreSQL 9.3 and includes read/write
support; a read-only version for 9.2 can be compiled and installed as
a contrib module.

contrib/dblink allows cross-database queries using function calls and
is available for much older PostgreSQL versions. Unlike postgres_fdw
it can’t “push down” conditions to the remote server,so it’ll often
land up fetching a lot more data than you need.

Of course,a client can also make simultaneous connections to different databases and merge the results on the client side.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读