ERROR[1451] Reported When a Table with Foreign Keys Cannot Be Deleted
Scenario
The root user does not have the permissions required to delete or modify tables in the database. Error message is as follows:
ERROR[1451] -Cannot deleteorupdatea parent row:
aforeignkeyconstraintfails (…)
Fault Analysis
The FRM file also exists in sys_tables. This table has foreign key relationships with other tables and cannot be deleted directly.
A foreign key association has been configured in the RDS for MySQL DB instance. As a result, data cannot be updated or deleted. You can use the foreign_key_checks parameter to avoid this problem.
Solution
set session foreign_key_checks=off; drop table table_name;
To delete the table, set foreign_key_checks to off.
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