sqlplus匯出記錄另存為CSV格式

westzq1984發表於2012-09-06
#################################################
##
## File name:   exp2csv.sh
## Author:      zhangqiao
## Copyright:   zhangqiaoc@olm.com.cn
##
#################################################

export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
export NLS_LANG=american_america.ZHS16GBK
mknod tmp.txt p
cat tmp.txt|grep -v "SQL>"|sed 's/^/"/'|sed 's/$/"/'|sed 's/ *",/",/g'|sed 's/" */"/g' > $2.csv &

sqlplus -S "/as sysdba" < /dev/null
set colsep '","'
set pagesize 0
set trimspool on
set trim off
set feedback off
set headsep off
set linesize 9999
set termout off
set numw 20
set arraysize 5000
spool tmp.txt
$1
spool off
EOF


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-742812/,如需轉載,請註明出處,否則將追究法律責任。

相關文章