Have tried searching this in
google[
^] prior to post here?
To execute a query in remote database you can use
dblink[
^]
insert into mytable
select *
from dblink('dbname=postgres hostaddr=xxx.xxx.xxx.xxx dbname=mydb user=postgres',
'select a,b from mytable')
as t1(a text,b text);
Or, you can also use
pg_dump to do that.
pg_dump -t table_to_copy source_db | psql target_db
Reference:
Copy a table from one database to another in Postgres[
^]
Hope, it helps :)