From: | Lucas Brito <lucas75(at)gmail(dot)com> |
---|---|
To: | Nicholas I <nicholas(dot)domnic(dot)i(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Comparing two tables of different database |
Date: | 2009-05-02 15:01:09 |
Message-ID: | cccdaefb0905020801i68426f57ycd892021bf27bd8b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Nicholas,
To use the dblink:
1. In your postgres server you should find a file *dblink.sql*.
In my beta installation is in *share/postgresql/contrib*. It is the
installation for the dblink contrib module that usually is already compiled
in. It will create a lot of dblink functions.
2. on database2 create a function nammed db_datbase1() which returns
"dbname=database1" (if you need a login use "dbname=database1 password=xxx",
you can also specify host= port= to connect in a remote postgresql database)
3. now execute the sql:
select * from dblink(db_database1(), 'select "id", "name", "time" from
pr_1') as pr_1("id" integer, "name" text, "time" time)
then you will see the table "pr_1" on the datbase2
--
Lucas Brito
From | Date | Subject | |
---|---|---|---|
Next Message | johnf | 2009-05-02 16:55:29 | using a list to query |
Previous Message | M.P.Dankoor | 2009-05-02 10:16:41 | Re: Comparing two tables of different database |