Dhruva Jain
Dhruva Jain

Reputation: 153

How do i insert into a MySQL db from a file?

My table has around 190 fields. Out of which only 30 cannot be null. And around 7k rows are to be inserted.

I am using JDBC. Is there anyway of inputting all these directly from a text file in a single INSERT instead of doing an INSERT statement 7k times.

Upvotes: 0

Views: 41

Answers (1)

Achrome
Achrome

Reputation: 7821

If you want to write a query itself, you can use LOAD DATA INFILE. It is a very fast method of importing a file. However, the file has to be properly formatted.

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

Upvotes: 1

Related Questions