Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using PostgreSQL

PostgreSQL 9.0.12, compiled by Visual C++ build 1500, 32-bit

I have two identical database on same server. I need to fetch data from a particular table from fist database and insert those data into other table in second database. I have read something about "EXTENSION" in postgres but I still don't get idea about how to use it.

So which is the better way to do it?

Any suggestion would help so much. Thank you.

share|improve this question
    
Your only option is dblink in your current version, but in a newer PostgreSQL you could instead use postgres_fdw, the SQL/MED foreign data wrapper support. –  Craig Ringer Jan 4 at 12:29

1 Answer 1

first open

share/contribs/dblink.sql

it is the path where postgreSQL is installed.

when you open this file , you will find some operations. copy it and paste it to the query window of your database and execute.

In my case i have executed this operations on both database.

now you will be able to run following kind of code

select * from dblink('dbname=databasename port=5432; password=P@ssw0rd123','select "id" from "State"') 
as P("id" bigint);
share|improve this answer
1  
Suggesting dblink is entirely sensible, but don't just copy and paste the SQL. On PostgreSQL versions that support extensions use CREATE EXTENSION dblink;. For ancient PostgreSQL versions instead use psql -1 -f /path/to/dblink.sql to load the extension. –  Craig Ringer Jan 4 at 12:28
    
P.S. not my downvote, hope the downvoter comments to indicate what their concerns are. –  Craig Ringer Jan 4 at 12:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.