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/目录下。

    -------在充满磨难和辛酸的人生道路上,只有你才能够掌握自己的命运!--------
  • 相关阅读:
    Redis之数据类型大全
    基于服务的SOA架构
    mybatis_个人总结
    mybatis_开发篇
    mybatis_基础篇
    mybatis_常用标签
    mybatis_映射查询
    solr_架构案例【京东站内搜索】(附程序源代码)
    Solr_全文检索引擎系统
    zabbix监控搭建步骤
  • 原文地址:https://www.cnblogs.com/lxplwh/p/7405602.html
Copyright © 2011-2022 走看看