MySQL批处理SQL语句

php中文网
发布: 2016-06-07 16:50:30
原创
1715人浏览过

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

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

--------------------------------------分割线 --------------------------------------

Ubuntu 14.04下安装MySQL

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

网聚购物系统
网聚购物系统

新功能:后台常用功能快捷导航 新订单提醒 新评论提醒 新注册用户提醒 后台自定义定制提醒刷新时间 不同管理员可以分别定制不同的通知 修正生成订单的时候出现sql错误! 修正商品自定义属性空格去处bug 批量转移商品 商品分类销售统计,数量统计 商品分类人气统计 升级订单系统,按日期搜索订单更快捷 订单统计功能 提高商品分类响应速度 批量打开商品开关 批量关闭商品 生成订单的时候出现sql错误! 商

网聚购物系统 0
查看详情 网聚购物系统

Ubuntu 14.04下搭建MySQL主从服务器

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址:

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号