Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009

    Unanswered: Performing Foreign Key Checks


    I have to write a complex script that inserts data into many tables. While the import there will be violated many foreign key constraints. Therefore I disabled them by "SET FOREIGN_KEY_CHECKS = 0".
    If I enable them after the inserstion by "SET FOREIGN_KEY_CHECKS = 1" MySQL performs no foreign key check so if I had inserted some corrupt data nobody will know it. Is it possible to enforce a foreign key check? Or is there any other way of securely inserting such data?

    Thanks in advance,

  2. #2
    Join Date
    Dec 2007
    Richmond, VA
    Provided Answers: 5
    Insert your data in order and let the database perform the checks at insert time. Its a lot easier than trying to circumvent it as you are.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts