MySQL Batch SQL statements

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.