alter table imageT drop foreign key fk_imageT_nodeT1; alter table imageT add constraint fk_imageT_nodeT1 foreign key (nodeId) references nodeT (id) on delete set null on update no action; /* SELECT * FROM imageT i left join nodeT n on i.nodeId = n.id WHERE n.id is null */