Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please explain briefly....thank you
Posted
Updated 1-Mar-16 1:13am

1 solution

Have tried searching this in google[^] prior to post here?

To execute a query in remote database you can use dblink[^]
SQL
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.
SQL
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 :)
 
Share this answer
 
v2
Comments
User-11630313 21-Aug-15 4:01am    
i tried pg_dump in different ways but syntax error occurs at the beginning of query "pg_dump" i don't understood why the error occurs?
anyway thanqqq for responding...@Shekhar

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900