How to delete foreign key

How to delete foreign key

camdaian159753@gmail.comcamdaian159753@gmail.com Posts: 3Questions: 2Answers: 0
edited October 2016 in Free community support

Help me, thanks ( English so bad)

table department (ID_dep , Name)

table lecturer(ID , Name, ID_dep)

delete ID_dep , error "SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails".

How do I delete a foreign key?

Answers

  • allanallan Posts: 64,951Questions: 1Answers: 10,758 Site admin

    Hi,

    What software you are using to do the delete? Is it Editor's PHP or .NET libraries? If so, what you'll need to do is either disallow deleting of rows which rows in other tables are dependent upon, or use ON DELETE CASCADE in your database so the child row is also deleted.

    Regards,
    Allan

This discussion has been closed.