我正在将记录从一个表复制到另一个表,并且某些记录可能已经在我要将记录复制到的第二个表中。
因为我正在复制很多行,所以我正在寻找一种方法来忽略来自 mysql 的所有记录已经存在的消息并继续执行 mysql 文件。
有什么方法可以抑制错误消息吗?
最佳答案
根据 INSERT
Syntax 记录:
The
INSERT
statement supports the following modifiers:[ deletia ]
- If you use the
IGNORE
keyword, errors that occur while executing theINSERT
statement are treated as warnings instead. For example, withoutIGNORE
, a row that duplicates an existingUNIQUE
index orPRIMARY KEY
value in the table causes a duplicate-key error and the statement is aborted. WithIGNORE
, the row still is not inserted, but no error is issued.
关于mysql - 执行sql文件时忽略mysql错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17656980/