PDA

View Full Version : MySQL LOAD DATA Overwrite



usedearplugs
12 Mar 2012, 07:26 AM
Is there code that will make LOAD DATA INFILE automatically overwrite any duplicates? Right now it appears to skip importing based on matching indexes.

If there is not a way to force overwrite, do you have any recommendations of how I would easily do this?

I am importing from a CSV file and what is in the CSV file should always take precedence over what's in the database. But there are other things in the same table in the database that will not have corresponding records in the file.

usedearplugs
12 Mar 2012, 08:10 PM
Nevermind, I found the answer.

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

LOAD DATA INFILE file_name REPLACE

Thanks anyways.