將 Oracle table 中的資料變成文字檔
2013-08-22 03:03
[oracle@voipdb1 report]$ cat allcdr.sh
###################################################################################
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
#ORACLE_TERM=xterm;
#export ORACLE_TERM
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch;
export PATH
###################################################################################
/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus voip/voip2013 <<EOF
set lines 200
set pages 50000
column FROM_UID format a10
column TO_UID format a10
column RESULT format a20
select from_uid,'#', to_uid, '#', duration,'#', to_char(starttime,'YYYY/MM/DD HH24:MI:SS') as startime, '#', to_char(endtime,'YYYY/MM/DD HH24:MI:SS') as endtime,'#', result,'#' FROM voip.cdr where starttime like sysdate-1 ;
exit
EOF
[oracle@voipdb1 report]$ cat getallcdr.sh
/home/oracle/report/allcdr.sh | grep '[0-9]\{8\}' > allcdr.log