Subject Re: [firebird-support] violation of FOREIGN KEY constraint "".
Author Milan Babuskov
Maurizio P. wrote:
> i am tring to add a foreign key to a table which contains some data ,
> and it seems i can't if i don't delete all the data to the (child) table ,
> fortunately it is only test data : i delete data and i can add the FK
> without any trouble .
> ... is it possible to add a FK without deleting data ?

Yes. You need to fix the data so that it doesn't break the FK
constraint. Find the problematic records like this:

select *
from child_table c
where not exists (
select 1
from parent_table p
where p.PK = c.FK)


> i use Firebird 1.5. and ibExpert .

<joke>
Try FB2.0 and FlameRobin ;)
</joke>

--
Milan Babuskov
http://njam.sourceforge.net
http://www.flamerobin.org