执行sql文件时忽略mysql错误消息(Ignore mysql error messages when executing an sql file)

系统教程 行业动态 更新时间:2024-06-14 16:59:17
执行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.

更多推荐

本文发布于:2023-04-16 14:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/c1dcf1e2fbcf128120209a5ae560f4b0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   消息   文件   mysql   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!