After instalation of Postgres 9.5 database server dblink function is not available. Trying to use it you will get error message that dblink is an unknown function.
So first step is to enable it by following command:
CREATE EXTENSION dblink;
As the next step is good to check connection to external database by using dblink_connect:
SELECT dblink_connect('alias-name', 'dbname=external_database user=username password=password');
Of course values like alias-name, external_database, username or password should be replaced with correct values.
If everything is fine it should return you just “OK”.
Then we can use connection to proceed with selects from external database:
SELECT * FROM dblink('dbname=external_database user=username password=password', 'select * from foo') AS t1(id integer, author character varying(255))