dguryev
5/26/2017 - 10:28 AM

Dblink alias setup

Dblink alias setup

CREATE EXTENSION postgres_fdw;
CREATE EXTENSION dblink;

CREATE SERVER {{server_alias}} FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '{{remote_ip}}', dbname '{{remote_db}}', port '5432');
CREATE USER MAPPING FOR {{current_db_user}} SERVER {{server_alias}} OPTIONS (user '{{remote_db_user}}', password '{{remote_db_password}}');

SELECT * FROM dblink('{{server_alias}}', 'SELECT 100500') AS t(test int);