MySQL batch processing SQL statements MySQL supports batch processing to execute a batch of SQL statements. the following example shows how MySQL executes SQL statements in windows batch processing.
Create table test (id int, name varchar (20); insert into test values (1, 'Watson ');
Batchfile.txt contains the following SQL statements, which are stored in c:/batchmysql/batchfile.txt of windows.
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
Insert into test select * from test;
In the cddl database, execute the preceding statement in batches: mysql-uroot-p-D cddl <c:/batchmysql/batchfile.txt
Below is the query information contained in the batch processing, and the output is saved to a file:
The corresponding batchfile2.txt contains query information (the following three SQL statements). The following mysql0716.out records the select * from test limit 200; query statement result set.
Select * from test limit 200;
Insert into test select * from test;
Insert into test select * from test;
You can catch the output in a file for further processing:
Mysql-uroot-p-D cddl <c:/batchmysql/batchfile2.txt> c:/batchmysql/mysql0716.out