Failed to Delete a Table with a Foreign Key
Scenario
When an RDS for MySQL table with a foreign key is deleted, the following error message will be displayed, which is irrelevant to user permissions:
ERROR 1451 (23000): Cannot delete or update parent row: a foreign key constraint fails …………
Possible Causes
There is a foreign key relationship between this table and another table. A link is established between the data in the two tables. To prevent foreign key constraints from being violated, data in the tables cannot be updated or deleted.
You can set FOREIGN_KEY_CHECKS to off to remove the foreign key relationship. For details, see FOREIGN KEY Constraints.
Solution
Set FOREIGN_KEY_CHECKS to off.
set session foreign_key_checks=off; drop table table_name;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot