水煮Oracle35----关于Oracle的sql*loader多表加载的容易忽略的position问题

       一个简单控制文件的编写:

--fields terminated by ',' enclosed by '"' ---如果数据的所有终止符号一样,设置默认终止符:whitespace(空格、tab、换行、换页、回车)/'string'
--badfile ---是指给的外部文件中不符合终止要求,不入库的数据
--discardfile---是指由when条件过滤掉的数据
--replace(先做delete,然后插入新行)、append(追加新行)、truncate(删除数据,然后替换)、insert
--when ---条件过滤
--trailing nullcols ---数据文件中没有,但是控制文件中有的列,这些列通过该语句置null
--nullif 条件、defaultif 条件
--begindata ---数据在控制文件中
--filler:过滤字段,不必在表中出现,主要用于when条件过滤,注意filler在position关键字前边
--注意:sqlloader读取平面文件中的数据是按照行读取的,即便是到下张表,也一直是按照行来读取的,所以position应用就急为重要在多表加载中
Options(direct=ture)
Load data
infile 'D:\sqlloader\b.csv' badfile 'D:\sqlloader\b.bad' discardfile 'D:\sqlloader\b.dsc'
Append
into table a1
when rowsid='1'
trailing nullcols
(
  rowsid filler char terminated by ',',
  sex  char  terminated by ',',
  Name char  terminated by ',')
into table a2
when rowsid='2'
trailing nullcols
(
  rowsid filler position(1) char terminated by ',',
  sex1  char  terminated by ',',
  Name1 char  terminated by ','
    )
into table a3
when rowsid='3'
trailing nullcols
(
  rowsid filler position(1)  char terminated by ',',
  sex  char  terminated by ',',
  Name char  terminated by ','
    )
 ------------------------------------------------------------------------------------
 The POSITION parameter in the second INTO TABLE clause is necessary to load this data correctly.
 It causes field scanning to start over at column 1 when checking for data that matches the second format.
 Without it, SQL*Loader would look for the recid field after dname.(摘之Oracle联机文档)
 ------------------------------------------------------------------------------------

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23890223/viewspace-1081285/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23890223/viewspace-1081285/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值