bad data with Foreign Key constraint

From: "Lee Wu" <Lwu(at)mxlogic(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: bad data with Foreign Key constraint
Date: 2004-06-18 22:51:27
Message-ID: ECAB83AA52BCC043A0E24BBC00001024111265@mxhq-exch.corp.mxlogic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi All,

I have found that there are some foreign keys in our detail tables while
there are not primary keys in master tables.

Yes, we have FK constraints on detail tables.

I could not think how it can happen. PG (7.3.2) does not have "disable
constraint" like Oracle, does it?

Sample data from PG:

select rid from c except select rid from r;

rid

-------------

7686396

7688003

7906141

7974816

8033807

(5 rows)

\d c

Table "public.c"

Column | Type |
Modifiers

---------------+--------------------------+-----------------------------
-----------------------

cid | integer | not null default
nextval('c_id_seq'::text)

rid | integer | not null

others...|

Indexes: c_pkey primary key btree (cid),

c_rid_idx btree (rid)

Foreign Key constraints: $1 FOREIGN KEY (rid) REFERENCES r(rid) ON
UPDATE NO ACTION ON DELETE CASCADE

Thank for your help!

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Lee Wu 2004-06-18 22:55:55 Re: table when vacuum questions
Previous Message Tom Lane 2004-06-18 22:26:09 Re: table when vacuum questions