时间:2021-07-01 10:21:17 帮助过:322人阅读
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