Mia Raunegger Mia Raunegger -4 years ago 100
MySQL Question

1452 - Cannot add or update a child row: a foreign key constraint fails

I'm getting this error:


1452 - Cannot add or update a child row: a foreign key constraint
fails.


I've located them and try to get rid of the references with

alter table tillhör drop foreign key kat_id;


But getting this error instead:


#1025 - Error on rename of '.\recept\tillh@1ir' to
'.\recept#sql2-1570-3cb' (errno: 152).


What do I do wrong?

Answer Source

Before you query run

SET FOREIGN_KEY_CHECKS=0

then set it to 1 after you`re done.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download