MySQL InnoDB table truncate fails because of foreign keys

Thursday, April 12, 2012 8:51
Posted in category Database

If trying to truncate MySQL InnoDB tables and you are getting an error because of foreign keys constraints try disabling the foreign keys checks.

SET FOREIGN_KEY_CHECKS = 0;
..
TRUNCATE tableName;
TRUNCATE tableName2;
..
SET FOREIGN_KEY_CHECKS = 1;

You can leave a response, or trackback from your own site.

Leave a Reply

Connect with Facebook