zoukankan      html  css  js  c++  java
  • 使用shell从DB2数据库导出数据

    使用shell脚本根据输入的用户名,数据库名,密码从DB2数据库导出数据

    (1)a.sh脚本如下

    #!/usr/bin/bash
    read -p "please input your DBNAME: " DBNAME
    read -p "please input your username: " username
    read -p "please input your password: " password
    db2 connect to $DBNAME user $username using $password
    db2 "EXPORT to /home/Practice/data/a.del of del select * from A"

    (2)连接Linux,使用下面命令执行

    su - db2inst1 -c "/home/Practice/a.sh"
    

    上面这条代码是关键,其中a.sh文件存储在/home/Practice路径下

    [root@localhost Practice]# chmod +x a.sh
    [root@localhost data]# su - db2inst1 -c "/home/Practice/a.sh"
    please input your DBNAME: oliverdb
    please input your username: db2inst1
    please input your password: db2inst1
    
       Database Connection Information
    
     Database server        = DB2/LINUXX8664 10.5.5
     SQL authorization ID   = DB2INST1
     Local database alias   = OLIVERDB
    
    SQL3104N  The Export utility is beginning to export data to file 
    "/home/Practice/data/a.del".
    
    SQL3105N  The Export utility has finished exporting "2" rows.
    
    
    Number of rows exported: 2

    到此处为止,数据已经从数据库oiliverDB导出到了目录/home/Practice/data下。

  • 相关阅读:
    谷歌浏览器本地调试时调用服务跨域
    SVN提交时忽略不必提交的文件夹和文件,如node_modules
    热点链接实现不规则菜单
    easyui分页控件的应用
    Filter过滤器的应用
    SVG绘图学习总结
    VS2010无法调试页面问题
    java学习
    webservice配置
    jQuery
  • 原文地址:https://www.cnblogs.com/OliverQin/p/5889244.html
Copyright © 2011-2022 走看看