zoukankan      html  css  js  c++  java
  • oraclesql脚本导出EXCEL数据

    在数据库中,经常有业务人员提出需求导出数据库中的业务数据,而且是每天、每周或每月定时导出。为了方便,可将sql查询的脚本 通过下面脚本来导出EXCEL数据。

    1.将查询sql脚本(AAA.sql)放到 相关目录如:/home/oracle/tongji-scripts/sql/AAA.sql

    2.# vim  sql-excel.sh

    source /home/oracle/.bash_profile
    export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
    export LANG=zh_CN.GBK

    function EXESQL(){
    sqlplus -s test/"123456" <<EOF
    set linesize 200
    set term off verify off feedback off pagesize 999
    set markup html on entmap ON spool on preformat off
    spool /home/oracle/tongji-scripts/result/$1_`date +%y%m%d`.xls
    @/home/oracle/tongji-scripts/sql/$1;
    spool off
    exit;
    EOF
    }

    for file in `ls /home/oracle/tongji-scripts/sql/`
    do
    EXESQL ${file}
    done

    3.添加定时任务: 00  03  *  *   *  /home/oracle/sql-excel.sh

    每天定时3点会将 /home/oracle/tongji-scripts/sql/下面的多个sql脚本导出 生成EXCEL文件 存放到 /home/oracle/tongji-scripts/result/目录下。

    -------在充满磨难和辛酸的人生道路上,只有你才能够掌握自己的命运!--------
  • 相关阅读:
    JVM
    事务
    Spring中AutowireMode(自动装配模型)
    ImportAware应用
    spring中几个比较重要的扩展点
    动态代理在Spring中的应用
    基于ImportSelector模拟简单的Aop
    正则表达式分组(Grouping)
    正则表达式断言(Assertions)
    一个JSON解析器
  • 原文地址:https://www.cnblogs.com/lxplwh/p/7405602.html
Copyright © 2011-2022 走看看