Since PostgreSQL 9.1, installation of additional modules is simple. Registered extensions like dblink
can be installed with CREATE EXTENSION
:
CREATE EXTENSION dblink;
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;
See:
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.
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.