I'm writing an application in Java where I need to insert text files into a MySQL table. These files can be tens of gigabytes. I've decided to use LOCAL INFILE to do this for performance reasons. The problem I'm running into is that I need to also insert a value based on a variable at the same time.
Assume the following table.
foo_string | bar_int
Assume the following data
a
bb
cccc
I'm first getting an id of a value from another table and storing it in a local int. Then I go to execute the following query to insert the values from myvalues.txt
statement.executeUpdate( "LOAD DATA LOCAL INFILE 'myvalues.txt' INTO TABLE mytable FIELDS TERMINATED BY '' LINES TERMINATED BY '\\n'");
The above works as expected but I'd also like to insert a value into the second (bar_int) column at the same time. What is the best way to do this?