Subject Unable to re-create foreign key
Author Ed Dressel
I've had a database that has shown problems (see

I've dropped the foreign keys and primary index that was causing the
problem and re-created the primary index. All is okay--until I try to
re-create a foreign key with:

alter table ACTIONLOG
add constraint FK1_ACTIONLOG
foreign key (CLIENT_ID)

I get the following exception:

Cannot commit transaction:
violation of FOREIGN KEY constraint "".
violation of FOREIGN KEY constraint "PK_CLIENTINFO" on table "CLIENTINFO".

I've checked

1) all client_id values in ActionLog are in ClientInfo:

select client_id from ClientLog where not client_id in
(select Client_Id from ClientInfo)

(which returns empty).

2) There are no null client_id values in ActionLog (or ClientInfo).

There is another tables where table.client_id has a fk on ClientInfo
and that one restored the fk just fine.

What might I look at?

Ed Dressel