append into table $tablename
fields terminated by '|'trailing nullcols
(
PHONE1,
PHONE2,
FLAG,
time_stamp
)
txt文件有3个字段phone1,phone2,flag第四个字段表示当前的日期是一个默认值文件中没有的,这个应该怎么赋值给time_stamp字段?
---------------------------------------------------------------------------------
试试
append into table $tablename
fields terminated by '|'trailing nullcols
(
PHONE1,
PHONE2,
FLAG,
time_stamp "sysdate"
)
---------------------------------------------------------------------------------
数据库中是date类型的字段可以,如果数据库中是varchar2的类型应该怎么弄呢?
---------------------------------------------------------------------------------
append into table $tablename
fields terminated by '|'trailing nullcols
(
PHONE1,
PHONE2,
FLAG,
time_stamp "to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')"
)
---------------------------------------------------------------------------------
如果默认为其它字符直接
time_stamp "abc"
---------------------------------------------------------------------------------
tablename="CJWS_USER_DAILY"
fileList="fileList.txt"
ctlpath="/app/tomcat/zjpii_collection/cjws"
ls -l $downloadpath | awk '{print $8}'
for fileName in `ls $downloadpath`
do
echo "
OPTIONS(
skip=0,
errors=500000)
load data
CHARACTERSET ZHS16GBK
infile '/app/tomcat/zjpii_collection/cjws/download/$fileName'
append into table $tablename
fields terminated by '|'trailing nullcols
(
MOBILE_NBR,
MUPT_NBR,
FLAG,
AREA_CODE "substr(:MUPT_NBR,2,3)"
time_stamp "sysdate"
)
" > $ctlpath/control.ctl
$ORACLE_HOME/bin/sqlldr cdr/cdr control=$ctlpath/control.ctl log=$ctlpath/control.log bad=$ctlpath/control.bad rows=1000
#del logfile
rm -fr $downloadpath/$fileName
done
---------------------------------------------------------------------------------