2011-03-20 73 views

回答

23

在MySQL Workbench中,我取消選中該選項下查詢到 「出錯停止腳本執行」:

enter image description here

看起來津巴布寶的答案也會起作用。


在新版本中使用 '觸發SQL腳本的執行是否應該繼續之後的語句失敗'

Toggle whether execution of SQL script should continue after failed statements

+0

謝謝你的提示!節省了很多時間。 – 2013-03-10 03:02:51

73

嘗試

mysql --force < sample_data.sql 

Mysql的幫助部分說

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

這不,如果工作使用-e選項。 – Jagger 2017-09-04 07:37:45

29

你也可以使用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