1 problem
when deleting data or tables associated with foreign keys, MySQL reports an error:
Cannot delete or update a parent row: a foreign key constraint fails
2 solution
SET foreign_key_checks = 0; // First set the foreign key constraint check off drop table mytable; // Delete the data, table or view SET foreign_key_checks = 1; // Turn on foreign key constraint checking to maintain the structural integrity of the table First turn off foreign key constraints, perform the delete operation, and then turn on foreign key constraints
Similar Posts:
- [Solved] MYSQL Error when deleting a table: Cannot delete or update a parent row: a foreign key constraint fails
- ORA-02292: integrity constraint
- DB2 Database table operation error SQL0668N Operation not allowed for reason code “1” on table “db”. S…
- ORA-30567: name already used by an existing [How to Solve]
- MySQL ERROR 1005: Can’t create table (errno: 150) [How to Solve]
- [Solved] MYSQL add foreign key error: Referencing column ‘xx’ and referenced column ‘xx’ in foreign key constraint ‘xxx’ are incompatible.
- MySQL exclude error 1114 holmium HY000 41 holmium“
- Python TypeError: __init__() missing 1 required positional argument: ‘on_delete’
- With check option in SQL
- This Row already belongs to another table error when trying to add rows?