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语句的更多相关文章

  1. Mysql 常用 SQL 语句集锦

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  2. Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  3. MySQL数据库sql语句的一些简单优化

    1.查询条件的先后顺序 有多个查询条件时,要把效率高能更精确筛选记录的条件放在后边.因为MySQL解析sql语句是从后往前的(不知是否准确). 例: select a.*,b.* from UsrIn ...

  4. mysql下sql语句 update 字段=字段+字符串

    mysql下sql语句 update 字段=字段+字符串   mysql下sql语句令某字段值等于原值加上一个字符串 update 表明 SET 字段= 'feifei' || 字段; (postgr ...

  5. MySQL数据库SQL语句基本操作

    一.用户管理: 创建用户: create user '用户名'@'IP地址' identified by '密码'; 删除用户: drop user '用户名'@'IP地址'; 修改用户: renam ...

  6. mysql执行sql语句过程

    开发人员基本都知道,我们的数据存在数据库中(目前最多的是mysql和oracle,由于作者更擅长mysql,所以这里默认数据库为mysql),服务器通过sql语句将查询数据的请求传入到mysql数据库 ...

  7. MySQL与SQL语句的操作

    MySQL与SQL语句的操作 Mysql比较轻量化,企业用的是Oracle,基本的是熟悉对数据库,数据表,字段,记录的更新与修改 1. mysql基本信息 特殊数据库:information_sche ...

  8. mysql 操作sql语句 目录

    mysql 操作sql语句 操作数据库 mysql 操作sql语句 操作数据表 mysql 操作sql语句 操作数据表中的内容/记录

  9. 不登录到MySQL执行SQL语句

    mysql -e 不登录到MySQL执行SQL语句 mysql -u root -p -e "SHOW DATABASES"

随机推荐

  1. 1091-Black Vienna

    描述 This problem is based on the game of Black Vienna. In this version there are three players and 18 ...

  2. H2O与Java线程同步

    Java 5以前的线程同步采用syncronized和wait,notify,notifyAll来实现,比较粗糙.之后有了Lock和Condition.ReentrantLock的简单lock,unl ...

  3. 关于linq

    其实从08年的时候,我就已经知道了linq,开始的时候也并没有注意,我说过很多次,我不是一个有心人,只是在新建立一个工程的时候,程序会自动引入linq这个玩意,怀着好奇的心去找了点资料,有的时候,看一 ...

  4. C​+​+​构​造​函​数​,​复​制​构​造​函​数​和​析​构​函​数​专​题

    链接:http://wenku.baidu.com/view/d9316c0e52ea551810a6872a.html 本文作者:黄邦勇帅本文是学习 C++中的最基本的内容,因此学习 C++就应全部 ...

  5. 逻辑运算符&& 用法解释

    A&&B 首先判断A,A成功然后判断B:A不成功则结束判断,返回false;

  6. Java问题汇集(1)

    1.javax.el.PropertyNotFoundException: Property 'Price' not found on type pet.petshop.dto.WareDto 简答: ...

  7. org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text

    代码缺少这一行:job.setInputFormatClass(KeyValueTextInputFormat.class);

  8. while MyJob = '程序员' do --- 序

    因为自己的际遇,忽然想写点什么留在这个世上.也许只是想证明自己活过吧. 所以,这不会是一个过去时的小说,这将是一个接近进行时的记叙.之所以是接近,因为我只有在空余时间,才能记录最近的经历.出于保护隐私 ...

  9. bzoj 1924 [Sdoi2010]所驼门王的宝藏(构图,SCC,DP)

    Description Input 第一行给出三个正整数 N, R, C. 以下 N 行,每行给出一扇传送门的信息,包含三个正整数xi, yi, Ti,表示该传送门设在位于第 xi行第yi列的藏宝宫室 ...

  10. Hibernate4搭建Log4J日志管理(附Log4j.properties配置详解)

    1.首先加入slf4j的jar包,即slf4j-api-1.6.1.jar 在hibernate官网下载hibernate-release-4.2.2.Final.zip并解压,在hibernate- ...