Foreign key restraints

Posted by & filed under Magento, mySQL.

Trying to import a Magento table into a database (drop table if exists) I got an error:

#1217 - Cannot delete or update a parent row: a foreign key constraint fails 

The way to get round this is to remove the foreign key constraint CHECK, delete the table, then add the check again:

SET FOREIGN_KEY_CHECKS=0
DROP TABLE cms_page
SET FOREIGN_KEY_CHECKS=1 

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Bitnami