MySQL Forums
Forum List  »  Newbie

Re: Foreign Key constraint fails
Posted by: Peter Brawley
Date: April 14, 2021 10:10AM

REPLACE INTO, a dubious MySQL extension for exactly the reason you tripped over.

When REPLACE INTO encounters an existing PK it's replacing, it deletes that row. The existence of FK references to your key prevents that (as it must, otherwise such references would be useless).

Your problematic REPLACE should be an UPDATE of the contact. And generally, where there are FKs, safer practice is to stick with INSERT and UPDATE.

Options: ReplyQuote


Subject
Written By
Posted
Re: Foreign Key constraint fails
April 14, 2021 10:10AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.