What is the best way to empty a self-referential MySQL table?
I have a self-referential MySQL table with a recursive parent_id: CREATE TABLE `recursive` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY `data_categorysource_parent_id` (`parent_id`), CONSTRAINT `parent_id_refs_id_627b4293` FOREIGN KEY (`parent_id`) REFERENCES `data_categorysource` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 During testing, I want to empty it but TRUNCATE fails: TRUNCATE `recursive` /* SQL Error: Cannot delete or update a parent row: a foreign key constraint fails... I currently have to manually