Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL cross server query?

Is there a way that I might query a database located on "Server 2" and get my data in "Server 1" ? That is return a set of records from a remote server to my local one.

PS: Not cross database query on same server because I know how to do that with dblink.

Update: great ty.

http://www.postgresonline.com/journal/index.php?/archives/44-Using-DbLink-to-access-other-PostgreSQL-Databases-and-Servers.html works like a charm. My bust was that I didn't see it on the dblink documentation on postgresql website.

like image 832
AlexRednic Avatar asked May 18 '10 10:05

AlexRednic


People also ask

Can you query across schemas Postgres?

If you just need results from multiple schemas, you can re-use the same query string and set the search_path in between: SET search_path = u111, public; SELECT * FROM foo; SET search_path = u222, public; SELECT * FROM foo; ... The schema search path search_path in Postgres works much like the search path a file system.


2 Answers

this is old - these days one would use the postgres_fdw module instead: https://www.postgresql.org/docs/9.3/static/postgres-fdw.html

like image 121
radiospiel Avatar answered Sep 22 '22 03:09

radiospiel


Apparently dblink can be used to query other servers - Using DbLink to access other PostreSQL Databases and Servers

like image 32
yozey Avatar answered Sep 24 '22 03:09

yozey