26

On MS SQL, I can do bulk insert using the sql command below:

BULK INSERT myDatabase.MyTable FROM 'C:\MyTextFile.txt' WITH FIELDTERMINATOR = ',' 

Now I want to do the same on MySQL but I can't seem to figure out how this works and what query to use.

1 Answer 1

32

In MySQL, the equivalent would be

LOAD DATA INFILE

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

LOAD DATA INFILE 'C:\MyTextFile' INTO TABLE myDatabase.MyTable FIELDS TERMINATED BY ',' 
Sign up to request clarification or add additional context in comments.

2 Comments

How would you do the 'ignore', as if I have a number "2,123.23" How would I ignore that comma
Thank you, here is more detailed overview of this and one more option: medium.com/@benmorel/high-speed-inserts-with-mysql-9d3dcd76f723

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.