且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 PostgreSQL 中使用(安装)dblink?

更新时间:2022-05-05 23:23:44

PostgreSQL 9.1 起,附加模块的安装很简单.注册的扩展,如 dblink 可以用 创建扩展:

Since PostgreSQL 9.1, installation of additional modules is simple. Registered extensions like dblink can be installed with CREATE EXTENSION:

CREATE EXTENSION dblink;

安装到您的默认架构中,默认为 public.在运行命令之前,请确保您的 search_path 设置正确.架构必须对所有必须使用它的角色可见.见:

Installs into your default schema, which is public by default. Make sure your search_path is set properly before you run the command. The schema must be visible to all roles who have to work with it. See:

或者,您可以通过以下方式安装到您选择的任何架构:

Alternatively, you can install to any schema of your choice with:

CREATE EXTENSION dblink SCHEMA extensions;

见:

每个数据库运行一次.或者在标准系统数据库template1中运行,自动将其添加到每个新创建的数据库中.手册中的详细信息.

Run once per database. Or run it in the standard system database template1 to add it to every newly created DB automatically. Details in the manual.

您需要先在服务器上安装提供模块的文件.对于 Debian 和衍生产品,这将是包 postgresql-contrib-9.1 - 对于 PostgreSQL 9.1,明显地.从 Postgres 10 开始,只有一个 postgresql-contrib 元包.

You need to have the files providing the module installed on the server first. For Debian and derivatives this would be the package postgresql-contrib-9.1 - for PostgreSQL 9.1, obviously. Since Postgres 10, there is just a postgresql-contrib metapackage.