MySQL's INSERT IGNORE INTO & foreign keys

Viewed 35152

Why in MySQL, INSERT IGNORE INTO does not change the foreign key constraint errors into warnings?

I'm trying to insert a number of records into a table and I expect MySQL to leave out the ones that result in error, any error, and insert the rest. Does anyone have any suggestions?

And the SET FOREIGN_KEY_CHECKS = 0; is not my answer. Because I expect the rows which defy the constraints not to be inserted at all.

Thanks

6 Answers

This issue seems to be fixed in MySQL 5.7, see https://bugs.mysql.com/bug.php?id=78853.

Now foreign key constraint error is turned into warning instead:

This issue exists in 5.1,5.5,5.6 builds but I see some improvements done in 5.7 where error has been converted to warning instead of error after WL#6614.

Related