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
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://blog.sqlauthority.com)
1 Comment. Leave new
Hello Pinal. I’m a veteran SQL Server DBA that wants to branch out into MySQL. Any suggestions where I might find some tutorials geared toward SQL Server vets?