MySQL批处理SQL语句_MySQL
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
下一篇: mysql中枚举类型之enum详解
推荐阅读
-
浅谈PL/SQL批处理语句:BULK COLLECT与FORALL对优化做出的贡献
-
MySQL利用profile分析慢sql详解(group left join效率高于子查询)
-
【SQL】Oracle和Mysql的分页、重复数据查询(limit、rownum、rowid)
-
MySQL查询本周、上周、本月、上个月份数据的sql代码介绍
-
MySQL5.7: sql script demo
-
mysql联合查询语句(关联两个不同数据库查询)
-
mysql 显示SQL语句执行时间的代码
-
MySQL 一次执行多条语句的实现及常见问题
-
SQL语句实例说明 方便学习mysql的朋友
-
MySQL 备份还原数据库批处理