Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group