mysql - 执行sql文件时忽略mysql错误信息

标签 mysql

我正在将记录从一个表复制到另一个表,并且某些记录可能已经在我要将记录复制到的第二个表中。

因为我正在复制很多行,所以我正在寻找一种方法来忽略来自 mysql 的所有记录已经存在的消息并继续执行 mysql 文件。

有什么方法可以抑制错误消息吗?

最佳答案

根据 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.

关于mysql - 执行sql文件时忽略mysql错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17656980/

相关文章:

php - PHP 中的依赖注入(inject)

python - scrapy exceptions.TypeError : 'int' object has no attribute '__getitem__'

mysql - 如何在 Laravel 5 中使用两个表中的两列来填充另一个表?

c# - 将类型 32 的整数传递给数据类型 INT 的 mysql 中定义的存储过程

php - mysql - 在有效的 INSERT 语法上返回 false

MySql 加载文件脚本和 2 个表

mysql - 使用字符串或 int 作为列值之间的权衡

php - 如何从一系列序列号中获取并在溢出后翻转

mysql - MariaDB 表卡住了

iphone - SQLite 和 MySQL order by 子句区别