zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    ioS开发之CoreLocation(GPS定位)
    iOSiOS开发之退出功能(易错)
    iOS开发之判断横竖屏切换
    iOS开发之左右抖动效果
    iOS开发之UIPopoverController
    thinkphp or查询
    Invalid left-hand side in assignment
    实现input表单从右向左输入
    thinkPhp不为空查询
    array_filter()用法
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/3866152.html
Copyright © 2011-2022 走看看