MySQL批处理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 < 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语句的更多相关文章
- Mysql 常用 SQL 语句集锦
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- MySQL数据库sql语句的一些简单优化
1.查询条件的先后顺序 有多个查询条件时,要把效率高能更精确筛选记录的条件放在后边.因为MySQL解析sql语句是从后往前的(不知是否准确). 例: select a.*,b.* from UsrIn ...
- mysql下sql语句 update 字段=字段+字符串
mysql下sql语句 update 字段=字段+字符串 mysql下sql语句令某字段值等于原值加上一个字符串 update 表明 SET 字段= 'feifei' || 字段; (postgr ...
- MySQL数据库SQL语句基本操作
一.用户管理: 创建用户: create user '用户名'@'IP地址' identified by '密码'; 删除用户: drop user '用户名'@'IP地址'; 修改用户: renam ...
- mysql执行sql语句过程
开发人员基本都知道,我们的数据存在数据库中(目前最多的是mysql和oracle,由于作者更擅长mysql,所以这里默认数据库为mysql),服务器通过sql语句将查询数据的请求传入到mysql数据库 ...
- MySQL与SQL语句的操作
MySQL与SQL语句的操作 Mysql比较轻量化,企业用的是Oracle,基本的是熟悉对数据库,数据表,字段,记录的更新与修改 1. mysql基本信息 特殊数据库:information_sche ...
- mysql 操作sql语句 目录
mysql 操作sql语句 操作数据库 mysql 操作sql语句 操作数据表 mysql 操作sql语句 操作数据表中的内容/记录
- 不登录到MySQL执行SQL语句
mysql -e 不登录到MySQL执行SQL语句 mysql -u root -p -e "SHOW DATABASES"
随机推荐
- HDU3362+状态压缩
dp[ i ]表示该状态下得所需花费. /* 状态压缩dp dp[i] = min( dp[ i-j ]+cost[ j ] ); 由i-j的状态转到i的状态 */ #include<stdio ...
- SQL跨表更新
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4384039.html] 前提:两张表要更新的字段.关联字段结构一致 更新库:FJPDI_TZ ...
- Android Service with Delphi 10 Seattle
http://delphi.org/2015/09/minimalistic-android-service-with-delphi-10-seattle/ http://delphi.org/201 ...
- 使用Html.fromHtml将html格式字符串应用到textview上面
在android中,有一个容易遗忘的Html.fromhtml方法,意思是可以将比如文本框中的字符串进行HTML格式化,支持的还是很多的, 但要注意的是要在string.xml中用<!--cda ...
- mysql select count(filed) 问题(where条件没有数据匹配的话也有数据返回)。
问题: SELECT count(*),user_id FROM tb_rp_logintrace WHERE id=-1 返回结果: count(*), user_id 0 ...
- PHP奇趣笔试试题一则
$a = 3; $b = 5; if($a = 5 || $b = 7){ $a++; $b++; } echo $a, ' ', $b; 输出结果为: A.6 8 B.6 6 C.2 6 D.1 6 ...
- Form表单中的三种查询方法
1.使用:parameter.G_query_find参数: IF (NAME_IN('PO_HEADERS.PO_HEADER_ID') IS NOT NULL) THEN :paramete ...
- Eclipse下Properties解析(重要的可修改的会用红笔标注)
以项目为例,打开Properties界面 显示如图: Resource(资源) 展开为 Builders Hibernate Settings Java Build Path(个人认为最重要的) Ja ...
- NOI2010超级钢琴
超级钢琴 [问题描述] 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度 ...
- [Irving]SQL去重复-DISTINCT用法
在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 distinct用于返回唯一不同的值. 表A: 示例1 select distinct nam ...