Continue SQL query even on errors in MySQL workbench

泪湿孤枕 提交于 2019-11-27 14:15:49

try

mysql --force < sample_data.sql 

Mysql help section says

 -f, --force         Continue even if we get an sql error.

You could also use INSERT IGNORE

INSERT IGNORE INTO mytable
 (primaryKey, field1, field2)
VALUES
 ('1', 1, 2),
 ('1', 3, 4), //will not be inserted
 ('2', 5, 6); //will be inserted
Steve

In MySQL Workbench, I unticked the option under Query to "Stop Script Execution on Errors":

It looks like Zimbabao's answer will work also.


In newer versions use 'Toggle whether execution of SQL script should continue after failed statements'

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!