执行sql文件时忽略mysql错误消息(Ignore mysql error messages when executing an sql file)
我正在将记录从一个表复制到另一个表,并且有可能某些记录可能已经在第二个表中,我正在将记录复制到。
由于我正在复制很多行,我正在寻找一种方法来忽略来自mysql的所有记录已经存在的消息并继续执行mysql文件。
有没有办法可以抑制错误信息?
I am copying records from one table to another and there is a chance that some records may already be in the second table i am copying the records to.
Since there are lots of rows i am copying,i am looking a way to ignore all the record already exists messages from mysql and continue executing the mysql file.
Is there a way i can suppress the error messages?.
最满意答案
如INSERT语法中所述 :
INSERT语句支持以下修饰符:
[ deletia ] 如果使用IGNORE关键字,则执行INSERT语句时发生的错误将被视为警告。 例如,如果没有IGNORE ,则复制表中现有UNIQUE索引或PRIMARY KEY值的行会导致重复键错误,并且语句将中止。 使用IGNORE ,仍未插入行,但未发出错误。
As documented under INSERT Syntax:
The INSERT statement supports the following modifiers:
[ deletia ] If you use the IGNORE keyword, errors that occur while executing the INSERT statement are treated as warnings instead. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error is issued.
更多推荐
发布评论