Created
April 11, 2016 11:36
-
-
Save maxclaus/33432f863091e51fd48b914d381b0a4b to your computer and use it in GitHub Desktop.
Example using dblink to execute a SELECT query between different databases. (PG 9.4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- enable dblink support | |
CREATE EXTENSION dblink; | |
-- create the connection | |
SELECT dblink_connect('myconn', 'dbname=tracking-service'); | |
-- then use the connection | |
SELECT "oauthId" | |
FROM "56_profile" local | |
INNER JOIN dblink('myconn','SELECT DISTINCT user_id FROM "event"') | |
AS remote(user_id int) | |
ON local.id = remote.user_id; |
Thanks for your example!
It was very helpful for me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I have one store function in postgres, which contains the scripts.(insert,update,delete).
I need to run the that stored function in required Database.
Generally in MSSQL Server, I used the USE command for navigating to required Database.
Please give me Advice how to do that ?