Postgres: dblink

(Last Updated On: )

Sometimes we need to connect to external database from within a query. There is an easy way to do this however before doing this make sure it meets your business requirements.

SELECT *
FROM dblink('dbname=##DBNAME## port=##PORT## host=##DBSERVER## user=##DBUSER## password=##PWD##', 'SELECT my fields FROM ##TABLE##') AS remote_data(my integer, fields varchar)