If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Performing Foreign Key Checks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-09, 05:49
olel olel is offline
Registered User
 
Join Date: Oct 2009
Posts: 23
Performing Foreign Key Checks

Hi,

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,
Ole
Reply With Quote
  #2 (permalink)  
Old 12-15-09, 12:43
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
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.

Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On