Re: referential integrity violations

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Shaun W(dot) Kruger" <shaun(at)linuxhost(dot)cc>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: referential integrity violations
Date: 2003-06-10 22:56:53
Message-ID: 6176.1055285813@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Shaun W. Kruger" <shaun(at)linuxhost(dot)cc> writes:
> I'm getting some pretty strange results when doing a mass
> create of my database structure. I get the following when
> it goes to create the foreign keys. I just can't figure out
> why it is that half of them complain and the other half don't.

> ERROR: groupidfk referential integrity violation - key
> referenced from users not found in groups

These are not syntax errors, they are complaints about your data --- ie,
there are rows in the tables that fail to meet the proposed foreign-key
constraint (there is no matching row in the referenced table).

I believe CVS tip has code in it to actually show the offending data
values, but right now you have to find the bad rows the hard way.
A SELECT ... WHERE NOT EXISTS ... kind of query should help.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaun W. Kruger 2003-06-10 22:56:58 referential integrity violations
Previous Message Ron Snyder 2003-06-10 22:50:27 error restoring large objects during pg_restore