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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

migrated from Mar 20 '13 at 5:34

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

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

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

Your Answer


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