View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 09:09 AM
Nuno
 
Posts: n/a
Default Foreign key constraint fails

Hello,

I have a sql script that create some tables and some of them have
foreign key restrictions like this:

alter table T_SCHEDULE_TO_DATAFLOW add constraint FK_T_SC_DF foreign
key (FK_SCHEDULE_ID)
references T_SCHEDULE (SCHEDULE_ID) on delete restrict on update
restrict;
alter table T_SCHEDULE_TO_DATAFLOW add constraint FK_T_SC_DF2 foreign
key (FK_DATAFLOW_ID)
references T_DATAFLOW (DATAFLOW_ID) on delete restrict on update
restrict;

I'm executing the same insert statement ('insert into
T_SCHEDULE_TO_DATAFLOW values (10,10,2);' and the 10 id is not valid)
in two diferent mysql databases (with the same sql script), one of
them is in the windows operative system and the other is in the linux.

Windows (XP) version of mysql is: mysql Ver 14.12 Distrib 5.0.27, for
win32
Linux (Suse server) version of mysql is: mysql Ver 14.12 Distrib
5.0.24a, for pc-linux-gnu (i686) using readline 5.0

And in windows i get what i'm was expecting:
ERROR 1452 (23000): Cannot add or update a child row: a foreign key
constraint f
ails (`fxsim/t_schedule_to_dataflow`, CONSTRAINT `FK_T_SC_DF` FOREIGN
KEY (`FK_S
CHEDULE_ID`) REFERENCES `t_schedule` (`SCHEDULE_ID`))

But in the linux the insertion return ok, and does not return the
foreign key constraint error.

Any idea why this happen, or if there is any configuration to activate
this constraints and if exists what is...

Thanks
Nuno

Reply With Quote