Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.

On this page
Help Center/ TaurusDB/ Troubleshooting/ SQL Issues/ Failed to Delete a Table with a Foreign Key

Failed to Delete a Table with a Foreign Key

Updated on 2023-10-19 GMT+08:00

Scenario

When a 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

A foreign key relationship exists 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

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback