views:

47

answers:

2

I am used to Oracle and to create a dblink in my schema and then access to a remote database like this : mytable@myremotedb, is there anyway do to the same with PostgreSQL ?

Right now I am using dblink like this :

SELECT logindate FROM dblink('host=dev.toto.com
                              user=toto
                              password=isok
                              dbname=totofamily', 'SELECT logindate FROM loginlog');

When I execute this command I get the following error : HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Does anybody have an idea ? Do we have to "activate" dblinks or do something before using them ?

Edit

Is there something to do on the remote database we are going to query? Do we have to activate dblink too ? I keep having a could not establish connection. This is the line is type :

SELECT dblink_connect_u('host=x.x.x.x dbname=mydb user=root port=5432');

IP Address is correct and postgres is running on the remote server. Any idea ?

+1  A: 

check if these links are helpful -

http://www.postgresonline.com/journal/archives/44-Using-DbLink-to-access-other-PostgreSQL-Databases-and-Servers.html

http://www.postgresql.org/docs/current/static/dblink.html

Sachin Shanbhag
Your first link helped me out. I didn't know it was part of contrib, so I didn't know I had to activate it. \i /usr/share/postgresql/8.4/contrib/dblink.sql made the trick ! Thank you !
Spredzy
+1  A: 

Installing modules usually requires you to run an sql script that is included with the database installation.

Assuming linux-like OS

find / -name dblink.sql

Verify the location and run it

Unreason