zoukankan      html  css  js  c++  java
  • Linux sh脚本用spool导出oracle数据库指定表表数据

    脚本如下,已验证可用,可配合crontab使用。
    1
    #!/bin/bash 2 3 cd /opt/oracle/datafor_kf 4 5 #redirect environment variables 6 source /opt/oracle/.bash_profile 7 8 #timestamp:YYYYmmdd 9 fdate=`date +%Y%m%d` 10 11 localGtFile="tcm_local_gtt_list_$fdate.txt" 12 allGtFile="tcm_all_gtt_list_$fdate.txt" 13 ecFile="tcm_ec_smsc_server_$fdate.txt" 14 spFile="tcm_sp_smsc_server_$fdate.txt" 15 16 17 #login 18 /opt/oracle/app/oracle/product/12.2.0/dbhome_1/bin/sqlplus uid/pwd@hostname:port/db<<EOF 19 SET echo off 20 SET feedback off 21 SET newpage none 22 SET pagesize 0 23 SET linesize 5000 24 SET verify off 25 SET term off 26 SET trims ON 27 SET heading off 28 SET trimspool ON 29 SET trimout ON 30 SET timing off 31 32 33 --tcm_local_gtt_list 34 spool "/home/ftp_kf/$localGtFile" 35 SELECT province||','||busi_city||','||area_code||','||gt||','||bel_hlr||','||spc||','||ser_type from TCM_GMSCSERVER_GT; 36 spool off 37 38 39 --tcm_all_gtt_list 40 spool "/home/ftp_kf/$allGtFile" 41 --used 42 SELECT province||','||busi_city||','||area_code||','||start_gt from TCM_CMCC_DATA_JT; 43 --test 44 --SELECT province||','||busi_city||','||area_code||','||start_gt from TCM_CMCC_DATA_JT where start_gt='1348803'; 45 spool off 46 47 48 --tcm_ec_smsc_server 49 spool "/home/ftp_kf/$ecFile" 50 --used 51 SELECT SERVER_CODE||','||EC_NAME||','||MAIN_ACCESS_ADDR||','||'hy' type from HY_SMGATE; 52 --test 53 --SELECT SERVER_CODE||','||EC_NAME||','||MAIN_ACCESS_ADDR||','||'hy' type from HY_SMGATE where SERVER_CODE='10037'; 54 spool off 55 56 57 --tcm_sp_smsc_server 58 spool "/home/ftp_kf/$spFile" 59 SELECT SERVER_CODE||','||SP_CONTENT_NAME||','||MAIN_ACCESS_ADDR from TCM_SP_NETGATE; 60 spool off 61 62 63 exit 64 EOF 65 66 #del line where it start by 'SQL' 67 /bin/sed -i '/SQL/d' $localGtFile 68 /bin/sed -i '/SQL/d' $allGtFile 69 /bin/sed -i '/SQL/d' $ecFile 70 /bin/sed -i '/SQL/d' $spFile 71 72 #del file before today 73 /bin/find /home/ftp_kf/* -mtime +1 -exec rm {} ;
  • 相关阅读:
    《Spring in action 4》(十一)SSM + Redis
    git 上传时报文件已存在的错
    JQuery--find与filter
    初识mysql
    并发--模块整理
    守护进程与守护线程
    用string模块生成随机验证码
    loggin 模块及其单例模式
    TCP协议--黏包现象
    网络编程---tcp/udp协议
  • 原文地址:https://www.cnblogs.com/jack-Leo/p/10085610.html
Copyright © 2011-2022 走看看