How to ignore below error while delete or update.
Error Code: 1451
Cannot delete or update a parent row: a foreign key constraint fails (`schema`.`refered_table_name`, CONSTRAINT `linked_key_ibfk_1` FOREIGN KEY (`reference_col`) REFERENCES `table_name` (`linked_column`))
|
How to ignore foreign key checks
-- this line tells to ignore foreign key checks
SET foreign_key_checks = 0;
-- delete all records
DELETE from user_info;
TRUNCATE user_info;
-- 1 value is not allow to remove or delete without constraints
SET foreign_key_checks = 1;
|