>  기사  >  데이터 베이스  >  MySQL批处理SQL语句_MySQL

MySQL批处理SQL语句_MySQL

WBOY
WBOY원래의
2016-06-01 13:06:331024검색

MySQL 支持批处理的模式执行一批SQL语句,下面的例子就是实验MySQL如何在windows下批处理执行SQL语句。

create table test(id int,name varchar(20));insert into test values(1,'watson');

batchfile.txt里包含下面的一些SQL 语句,此文件放在windows系统的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;

在cddl数据库里进行批执行上面的语句如下:mysql -uroot -p -D cddl

下面是把批处理里含有查询的信息,输出保存到一个文件里:

此时的batchfile2.txt里含有query的信息(下面的3条SQL语句),下面的mysql0716.out就记录了select * from test limit 200;查询语句的结果集。

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/mysql0716.out

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.