Re: Comparing two tables of different database

From: Joshua Tolley <eggyknap(at)gmail(dot)com>
To: Adam Ruth <adamruth(at)mac(dot)com>
Cc: Pawel Socha <pawel(dot)socha(at)gmail(dot)com>, Nicholas I <nicholas(dot)domnic(dot)i(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Comparing two tables of different database
Date: 2009-04-30 03:37:48
Message-ID: 20090430033747.GB1126@eddie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Apr 30, 2009 at 08:20:02AM +1000, Adam Ruth wrote:
> The simple answer is to pg_dump both tables and compare the output with
> diff.
> Other than that, I think you'll need a custom program.

For all but the strictest definition of "identical", that won't work.
Tables may easily contain the same information, in different on-disk
order, and pg_dump will most likely give the data to you in an order
similar to its ordering on disk.

Something like a COPY (<query>) TO <file>, where <query> includes an
ORDER BY clause, might give you a suitable result from both tables, on
which you could then take a checksum.

- Josh / eggyknap

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Nicholas I 2009-04-30 10:12:16 Re: Comparing two tables of different database
Previous Message Adam Ruth 2009-04-29 22:20:02 Re: Comparing two tables of different database