MYSQL – Could not Drop Object [Content] (‘Cannot delete or update a parent row: a foreign key constraint fails’, 1217) DROP DATABASE DatabaseName

If you are using MySQL following, you must have faced following error when you want to drop a table or database. This error happens when we try to drop a table or database which has a foreign key constraint associated with another table, schema or database.

Could not Drop Object [Content] (‘Cannot delete or update a parent row: a foreign key constraint fails’, 1217) DROP DATABASE DatabaseName

MYSQL - Could not Drop Object [Content] ('Cannot delete or update a parent row: a foreign key constraint fails', 1217) DROP DATABASE DatabaseName mysqlerror

Here is a simple workaround to this problem. Disable the keys right before you drop a table or a database. Remember to practice this on the database which you are confident to drop it.

SET FOREIGN_KEY_CHECKS=0;
DROP DATABASE humanresources;
DROP TABLE MyTable;
SET FOREIGN_KEY_CHECKS=1;

Let me know if you are using any method for this purpose.

Reference: Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com)

MySQL, SQL Error Messages
Previous Post
SQL SERVER – Synchronize Schema across Multiple Environment – How to Overcome Database Migration Challenge
Next Post
MySQL – Download MySQL Workbench Shortcut in PDF

Related Posts

Leave a Reply