MySQL Forums
Forum List  »  Newbie

Re: Load data infile help
Posted by: Rick James
Date: May 19, 2014 12:10PM

If your CSV file consistently has 5 columns, but your table has 7 columns, then look at the LOAD command to see how to load only the 5 columns and ignore the other 2 columns.

If you are saying that the table currently has 5 columns, but new data (and CSV) has 7 columns, then consider this:
0. Create a new table with the two new columns (plus id for joining to original table)
1. LOAD the CSV into a temporary table with 7 columns.
2. INSERT ... SELECT to copy the 5 columns into the main table.
3. INSERT ... SELECT to copy the 2 columns into the new table.

Options: ReplyQuote


Subject
Written By
Posted
May 16, 2014 09:16AM
Re: Load data infile help
May 19, 2014 12:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.