Cannot truncate a table referenced in a foreign key constraint (`video_clips`.`channel_clips`, CONSTRAINT `clips_fk` FOREIGN KEY (`clip_id`) REFERENCES `video_clips`.`clips` (`id`)) in sql] 1

Cannot truncate a table referenced in a foreign key constraint (`video_clips`.`channel_clips`, CONSTRAINT `clips_fk` FOREIGN KEY (`clip_id`) REFERENCES `video_clips`.`clips` (`id`)) in sql]

SET FOREIGN_KEY_CHECKS = 0; 

truncate table "yourTableName";

SET FOREIGN_KEY_CHECKS = 1;

Here is what the above code is Doing:
1. Setting the foreign key checks to 0. This will allow you to truncate the table even if there are foreign key constraints.
2. Truncating the table.
3. Setting the foreign key checks back to 1.

Similar Posts