mysql> select * from foo;+----+------+| id | u |+----+------+| 1 | 20 |+----+------+mysql> replace into foo (u) values (20);mysql> select * from foo;+----+------+| id | u |+----+------+| 3 | 20 |+----+------+
CREATE TABLE test(id BIGINT (20) UNSIGNED AUTO_INCREMENT,str VARCHAR(20),PRIMARY KEY(id),UNIQUE(str));
INSERT INTO test (str) VALUES('A'),('B');
/* duplicate key error caused not by the insert,but by the update: */INSERT INTO test (str) VALUES('B')ON DUPLICATE KEY UPDATE str='A';
/* duplicate key error is suppressed */INSERT IGNORE INTO test (str) VALUES('B')ON DUPLICATE KEY UPDATE str='A';