shell脚本将txt文件导入oracle

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

---------------------------------------------------------------------------------

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值