当前位置:Gxlcms >
数据库问题 >
Linux sh脚本用spool导出oracle数据库指定表表数据
Linux sh脚本用spool导出oracle数据库指定表表数据
时间:2021-07-01 10:21:17
帮助过:68人阅读
#!/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 数据 数据库