Re: referential integrity violations

Started by Tom Lanealmost 23 years ago1 messagesgeneral
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

"Shaun W. Kruger" <shaun@linuxhost.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