Export MySQL data to separate txt files
I have a MySQL database dump of about 250,000 records. I am very new to MySQL, and I need e开发者_Go百科ach of these records exported into their own .txt file. Is there any way to do this using MySQL? If not, could I do this with Java code?
Thank you.
You can output a select statement to a file but only one file at a time
SELECT * FROM TABLE
INTO OUTFILE '/tmp/outputfile.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
I would recommend outputting from MySQL into a single file and then breaking that file up using split
in Linux (hopefully that's your OS)
split -l 1 -a 20 outputfile.csv
If it says output file suffixes exhausted, you will have to increase the -a value to something higher
精彩评论