Re: compare 2 tables in sql

From: "Dean Gibson (DB Administrator)" <postgresql(at)ultimeth(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: compare 2 tables in sql
Date: 2008-03-19 22:00:31
Message-ID: 47E18CFF.2020408@ultimeth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 2008-03-19 10:56, Tena Sakai wrote:
>
> Hi Everybody,
>
> Is there a sql way to compare (in a diff/cmp sense) 2 tables? For
> example,
>
> create table foo as
> [select bla bla bla];
>
> create table moo as
> [select bla bla bla];
>
> How would I go about knowing foo and moo are identical (or not)? Any
> pointer would be appreciated.
>
> Tena
>
You could do a full outer join of "foo" and "moo" on whatever is the
common key, and then delete those rows which don't have null fields in
the either the left or right sides; the remainder would be the differences.

--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jonah H. Harris 2008-03-19 22:39:34 Re: compare 2 tables in sql
Previous Message Preston Landers 2008-03-19 20:24:12 Re: pg_dump using SQL