This is a very simple task. To do this, use dblink:
INSERT INTO t(a, b, c)
SELECT a, b, c FROM dblink('host=xxx user=xxx password=xxx dbname=xxx', 'SELECT a, b, c FROM t') AS x(a integer, b integer, c integer)
If you need to regularly receive data from an external database, it would be wise to determine the mapping of servers and users. Then you can use a shorter statement:
dblink('yourdbname', 'your query')
source
share