码迷,mamicode.com
首页 > 数据库 > 详细

MySQL批处理SQL语句

时间:2014-07-24 22:01:53      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:文件   数据   art   for   re   c   div   ar   

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 < c:/batchmysql/batchfile.txt

 

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

此时的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/batchfile2.txt >c:/batchmysql/mysql0716.out

MySQL批处理SQL语句,布布扣,bubuko.com

MySQL批处理SQL语句

标签:文件   数据   art   for   re   c   div   ar   

原文地址:http://www.cnblogs.com/zfyouxi/p/3866152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!