bad data with Foreign Key constraint - Mailing list pgsql-admin

From Lee Wu
Subject bad data with Foreign Key constraint
Date
Msg-id ECAB83AA52BCC043A0E24BBC00001024111265@mxhq-exch.corp.mxlogic.com
Whole thread Raw
Responses Re: bad data with Foreign Key constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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!

 

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: table when vacuum questions
Next
From: "Lee Wu"
Date:
Subject: Re: table when vacuum questions