in mysql database,how to upload the modified data from csv file
Initially, I created a database called开发者_开发百科 "sample" and updated the data from massive size CSV file.
Whenever I have small changes in .csv file (some data are added/deleted/modified), I have to update this in database too. Always updating the entire .csv file (large) is not efficient.
Is there any efficient way to update the modified data from .csv file to database?
Assuming that you are using LOAD DATE INFILE for importing from CSV, try using this syntax:
LOAD DATA INFILE 'file_name'
IGNORE
INTO TABLE `tbl_name`
...
...
IGNORE keyword will skip any rows in the CSV that duplicate any existing row in the table causing a conflict with a unique key. Read more here.
This will be more quicker and efficient than importing the complete CSV again.
精彩评论