MySQL supports batch-mode execution of batches of SQL statements, and the following example is how MySQL executes SQL statements under Windows batch processing.
CREATE TABLE Test (ID int,name varchar (20));
INSERT into test values (1, ' Watson ');
The batchfile.txt contains some of the following SQL statements, which are placed on the Windows system's C:/batchmysql/batchfile.txt
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, the following statements are executed in batches:
Mysql-uroot-p-D CDDL < C:/batchmysql/batchfile.txt
The following is a batch containing the query information, the output is saved to a file:
At this point the Batchfile2.txt contains the query information (the following 3 SQL statements), the following Mysql0716.out records the SELECT * from test limit 200; The result set of the query statement.
SELECT * from test limit 200;
INSERT INTO Test select * from test;
INSERT INTO Test select * from test;
You can catch the output of a file for further processing:
Mysql-uroot-p-D CDDL < C:/batchmysql/batchfile2.txt >c:/batchmysql/mysql0716.out