且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

mySQL INSERT IGNORE不会“忽略".

更新时间:2022-04-30 08:02:45

INSERT语法:

没有IGNORE的情况下,与表中现有的UNIQUE索引或PRIMARY KEY值重复的行会导致重复键错误,并且该语句将中止.使用IGNORE,仍不会插入该行,但不会发出错误.

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.

您需要在md5sum上定义UNIQUE索引:

ALTER TABLE rss_feeds ADD UNIQUE INDEX (md5sum);