logicslab Posted December 5, 2011 Share Posted December 5, 2011 Hi pals, I create 2 tables with name tbl_project and tbl_issue and I plan to give Foreign key constraint for tbl_issue by giving alter table command as "ALTER TABLE `testdrive`.`tbl_issue` ADD CONSTRAINT `FK_issue_project` FOREIGN KEY (`project_id`) REFERENCES `tbl_project`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT" It's successfully executed and when I check the table tbl_issue I found the Alter table command as "ALTER TABLE `tbl_issue` ADD CONSTRAINT `FK_issue_project` FOREIGN KEY (`project_id`) REFERENCES `tbl_project` (`id`) ON DELETE CASCADE;" there missing the "UPDATE RESTRICT" , I feel wonder why this like that ? Do you any one can explain why this ? If you have idea PLS EXPLAIN THANKS ANES Quote Link to comment https://forums.phpfreaks.com/topic/252490-add-foreign-constraint-doubt/ Share on other sites More sharing options...
mikosiko Posted December 5, 2011 Share Posted December 5, 2011 RESTRICT is the default option for ON DELETE and ON UPDATE, therefore they are not included as part of the table description. Quote Link to comment https://forums.phpfreaks.com/topic/252490-add-foreign-constraint-doubt/#findComment-1294614 Share on other sites More sharing options...
logicslab Posted December 6, 2011 Author Share Posted December 6, 2011 Thanks Mikosiko for your clear reply .... Do you can suggest a good book for advanced mySql ideas? thanks Anes Quote Link to comment https://forums.phpfreaks.com/topic/252490-add-foreign-constraint-doubt/#findComment-1294825 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.