码迷,mamicode.com
首页 > 数据库 > 详细

Linux sh脚本用spool导出oracle数据库指定表表数据

时间:2018-12-07 23:25:12      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:bho   exe   pre   serve   inux   data   set   数据   数据库   

脚本如下,已验证可用,可配合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 {} \;

 

Linux sh脚本用spool导出oracle数据库指定表表数据

标签:bho   exe   pre   serve   inux   data   set   数据   数据库   

原文地址:https://www.cnblogs.com/jack-Leo/p/10085610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!