Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a CSV file that contains a lot of integer values. Is it better to insert these individual values in bulk as in a full transaction or should I be inserting the CSV file itself into the MySQL?

share|improve this question
1  
What are you going to do with the data after it is in the database? That would probably help give some perspective that would help with answers. –  Mark Wilkins Mar 15 '13 at 22:51
add comment

migrated from stackoverflow.com Mar 20 '13 at 5:34

This question came from our site for professional and enthusiast programmers.

1 Answer

Insert the individual values in bulk. In other words, each row of the csv file should become a row in the database with the same number of columns.

Using Notepad++ you can use a regex find and replace to easily convert your CSV into a very large insert statement. Replace \r\n with '),(' and , with ','. Tidy up the first and last line of the file, then add the actual insert statement to the front. insert into table (col1, col2, col3) values .....

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.