The project needs to import excel files in batches. what should I do if there is duplicate data in it? Do I need to query the database every time data is inserted? The project needs to import excel files in batches. what should I do if there is duplicate data in it? Do I need to query the database every time data is inserted?
Reply content:
The project needs to import excel files in batches. what should I do if there is duplicate data in it? Do I need to query the database every time data is inserted?
1. what should I do if there is duplicate data in it?
You can first determine whether the database has the data.
2. do I need to query the database every time data is inserted?
Yes.
First re-obtain the data that is not duplicated, and then insert the data into the database in batches. You can also try insert ignore into or replace into in MYSQL.
If the query is slow, add a unique key to fields that cannot be repeated, and then useINSERT IGNORE