mysql text file introduction and batch processing mode application description

MySQL text file introduction and batch processing mode application description, friends who need can refer to it.
1 Load the records in the text file into the MySQL database table
(1) Text file format: one record of each line, the field value is separated by the TAB positioning symbol, the sequence of the field and the order of the table definition;
(2)LOAD DATA LOCAL INFILE ‘pet.txt’ INTO TABLE pet;
Note: If you use Windows editor, you should use:
LOAD DATA LOCAL INFILE ‘pet.txt’ INTO TABLE pet
LINES TERMINATED BY ‘\r\n’;

2 Batch of processing mode Run MySQL
(1) Place the MySQL statement you want to run in a text file Batch-File.txt;
(2) Execution: MySQL -H Host -u User -P <BATCH -FILE.txt;
(3) Reset the output to the file out.txt:
mysql -h host -u user -p < batch-file.txt > out.txt;
From mysql prompts to run script:
mySQL> Source Batch-file.txt; or mysql> \. Batch-file.txt;

Leave a Reply

Your email address will not be published. Required fields are marked *