Re: [SQL] comparing 2 tables. . .

From: Eric BASIER <basier(at)ipgp(dot)jussieu(dot)fr>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>, PGSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] comparing 2 tables. . .
Date: 1999-09-24 14:32:00
Message-ID: 37EB8B5F.23F9CA40@ipgp.jussieu.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

You can try this, (but i think it may take a long time )
1 : Find which tuples are in t1 and not in t2
select distinct t1.pk from t1 where t1.pk not in (select t2.pk from t2);
2 : Find which tuples are in t2 and not in t1
select distinct t2.pk from t2 where t2.pk not in (select t1.pk from t1);
In the case that you only want to known the references

If you want to rebuilt your table after analyze you can make this :
select distinct t1.pk into t1b from t1 where t1.pk not in (select t2.pk
from t2);
select distinct t2.pk into t2b from t2 where t2.pk not in (select t1.pk
from t1);
After your analyze you can insert tuples of table t1b into table t1 and
tuples of table t2b into table t2.

Regards

--
Basier Eric e-mail : basier(at)ipgp(dot)jussieu(dot)fr
http://geoscope.ipgp.jussieu.fr
IPGP Observatoires Sismologie-Volcanologie
4,Place Jussieu 75005 Paris Tour 24-14 4eme Etage Tel 01 44 27 38 96

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stuart Rison 1999-09-24 14:32:51 RE: [SQL] comparing 2 tables. . .
Previous Message Daniel Péder 1999-09-24 14:06:33 RE: [SQL] comparing 2 tables. . .