Re: Comparing two tables of different database

From: "M(dot)P(dot)Dankoor" <m(dot)p(dot)dankoor(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Comparing two tables of different database
Date: 2009-05-02 10:16:41
Message-ID: 49FC1D89.2070007@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In case dblink was not installed, you could try the following:

1. dump only the data from the table from database 1
pg_dump -U username -a -d -t tablename dbname > tablename.sql

2. create a (temp) table in database 2
SELECT * INTO tablename_bak from tablename WHERE 1 = 2

3. restore the dumped data in the bak table in database 2
pg_restore -U username -a -t tablename_bak dbname tablename.sql

4.select * from tablename except select * from tablename_bak

or you could dump the data from both tables and use some kind of diff tool

Nicholas I wrote:
> Hi,
>
> can anybody me suggest me, how to compare two tables of different
> database.
>
> -Nicholas I

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Lucas Brito 2009-05-02 15:01:09 Re: Comparing two tables of different database
Previous Message Wei Weng 2009-05-01 16:31:12 Re: Comparing two tables of different database