Cette page n'est pas encore disponible dans votre langue. Nous nous efforçons d'ajouter d'autres langues. Nous vous remercions de votre compréhension.

On this page
Help Center/ Relational Database Service/ Troubleshooting/ RDS for MySQL/ SQL Issues/ ERROR[1451] Reported When a Table with Foreign Keys Cannot Be Deleted

ERROR[1451] Reported When a Table with Foreign Keys Cannot Be Deleted

Updated on 2022-09-21 GMT+08:00

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.

The foreign key association has been set in the RDS for MySQL DB instance. As a result, data cannot be updated or deleted. You can set foreign_key_checks 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

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback