Rafal, ----- Original Message ----- From: "Rafal Kedziorski" <[EMAIL PROTECTED]> Newsgroups: mailing.database.mysql Sent: Monday, July 28, 2003 6:52 PM Subject: TRUNCATE problem ...
> hi, > > I have this table: > > CREATE TABLE `category_tree` ( > `category_tree_id` BIGINT NOT NULL AUTO_INCREMENT, > `parent_id` BIGINT, > `mandant_id` SMALLINT NOT NULL, > `partner_id` SMALLINT NOT NULL, > `class_id` VARCHAR ( 32) NOT NULL, > `position` SMALLINT NOT NULL, > `path` VARCHAR (255), > `description` VARCHAR (255) NOT NULL, > # > PRIMARY KEY (`category_tree_id`), > INDEX (`parent_id`), > INDEX (`mandant_id`), > INDEX (`partner_id`), > FOREIGN KEY (`parent_id`) > REFERENCES `category_tree` (`category_tree_id`), > FOREIGN KEY (`mandant_id`) > REFERENCES `mandant` (`mandant_id`), > FOREIGN KEY (`partner_id`) > REFERENCES `partner` (`partner_id`) > ) TYPE=InnoDB; > > > After call: > > TRUNCATE TABLE `category_tree`; > > I get this error message: > > TRUNCATE TABLE `category_tree` > Cannot delete or update a parent row: a foreign key constraint fails > > While there is an foreign key on each self. Is this a Bug in MySQL? TRUNCATE is still implemented as DELETE FROM ... It is in the TODO list to implement it as DROP + CREATE. Workarounds: put ON DELETE CASCADE to the definition. Or SET FOREIGN_KEY_CHECKS=0 before the TRUNCATE. > Regards, > Rafal Best regards, Heikki Tuuri Innobase Oy http://www.innodb.com Transactions, foreign keys, and a hot backup tool for MySQL Order MySQL technical support from https://order.mysql.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]