In MySQL, insert operations are often used in three types
One is direct insert into, the other is insert ignore into, and the other is replace.
Insert into is the most commonly used insert operation. When the primary key or unique index has duplicate values, an error is reported directly.
Insert ignore into is functionally the same as insert into, but it has the advantage that when the primary key or unique index already exists, insert ignore and insert, this avoids duplicate data in the database. This method greatly improves the efficiency and avoids a single query statement when you do not need to give feedback on the inserted results when you need to frequently query the data.
Replace into is a little different from the insert ignore into function. It is used to update data. It is mainly used to replace and update the data when the index data is duplicated.
In short, these three methods have their own advantages, which can avoid the trouble of querying data during database operations.