MySQL batch processing SQL statement _ MySQL

Source: Internet
Author: User
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

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.