For primary key conflicts, automatically ignores the records that are currently being inserted. When a uniqueness constraint is violated, the data currently being inserted is also discarded.
Can be used in the data synchronization scene, this scene data source only inserts the action, if the data source contains the update will fail, cannot synchronize Update field. This is done eventually and idempotent.
Mysql> select * from test_table; +----+------+
| ID |
KK | +----+------+
| 1 | 1 | | 3 | 2 | | 4 | 3 | | 6 |
5 |
+----+------+ 4 rows in Set (0.01 sec) mysql> Show create TABLE test_table; +------------+-------------------------------------------------------------------------
------------------------ --------------------------------------+
| Table |
Create Table | +------------+-------------------------------------------------------------------------
------------------------ --------------------------------------+
| test_table |
CREATE TABLE ' test_table ' (' id ' int () NOT null auto_increment, ' KK ' varchar () DEFAULT null, PRIMARY KEY (' id '),
UNIQUE KEY ' kk_uq ' (' KK ') engine=innodb auto_increment=7 DEFAULT charset=latin1 | +------------+-------------------------------------------------------------------------
------------------------ --------------------------------------+ 1 row in Set (0.00 sec) mysql> Insert ignore into test_table (ID, KK) VALUES (6,7);
Query OK, 0 rows affected (0.01 sec) mysql> Insert ignore into test_table (ID, KK) VALUES (6,5);
Query OK, 0 rows Affected (0.00 sec) mysql> Insert ignore into test_table (ID, KK) VALUES (5,5);
Query OK, 0 rows affected (0.01 sec) mysql> Insert ignore into test_table (ID, KK) VALUES (5,4);
Query OK, 1 row affected (0.02 sec) mysql> select * from test_table; +----+------+
| ID |
KK | +----+------+
| 1 | 1 | | 3 | 2 | | 4 | 3 | | 5 | 4 | | 6 |
5 | +----+------+ 5 rows in Set (0.00 sec)