创建如下临时表:
create table TEST
(
  ID1 NUMBER(3) not null,
  ID2 NUMBER(3) default 1 not null,
  ID3 NUMBER(3) default 2 not null
)
其中ID1是主键数据文件中只要ID2的值,ID1希望根据序列生成,ID3使用默认值
sqlldr的控制文件如下:
load data 
INFILE 'test.txt' 
INTO TABLE test 
 APPEND 
FIELDS TERMINATED BY ',' 
TRAILING NULLCOLS( 
  ID2,
  ID1 sequence(max,1)     
 ) 数据文件内容如下:
3
2
我觉得这样配置时,导入的数据应该是ID1是自增的,ID2是文本文件中的,ID3为默认值
但执行sqlldr导入数据时
D:\>sqlldr user1/user1@testdb control=test.ctl  direct=true log =test.logSQL*Loader: Release 9.2.0.8.0 - Production on 星期二 10月 26 13:43:50 2010
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
SQL*Loader-951:  呼叫一次/加载初始化错误
ORA-26010: Column ID3 in table TEST is NOT NULL and is not being loaded请教各位大侠,这个问题该怎么解决。数据文件是不能修改的,控制文件中也不能加ID3,多谢!

解决方案 »

  1.   

    direct path是不會去處理default值的,所以只能不用direct選項了
      

  2.   

    ORA-26010: Column ID3 in table TEST is NOT NULL and is not being loaded
    id3 不能为空 或者
    alter table test modify id3 default 2 null要么把id3加进去
    C:\>sqlldr scott/sys@orcl control=d:\sqlldr\test.ctl direct=true log=d:\test.log
    SQL*Loader: Release 10.2.0.1.0 - Production on 星期五 10月 22 15:04:11 2010Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    加载完成 - 逻辑记录计数 1。
      

  3.   

    --direct=falseC:\>sqlldr scott/sys@orcl control=d:\sqlldr\test.ctl direct=false log=d:\test.lo
    gSQL*Loader: Release 10.2.0.1.0 - Production on 星期五 10月 22 15:06:07 2010Copyright (c) 1982, 2005, Oracle.  All rights reserved.达到提交点 - 逻辑记录计数 1
    SQL> select * from test
      2  /       ID1        ID2        ID3
    ---------- ---------- ----------
             1          3          2
      

  4.   


    Field Defaults on the Direct PathDefault column specifications defined in the database are not available when you use direct path loading. Fields for which default values are desired must be specified with the DEFAULTIF clause. If a DEFAULTIF clause is not specified and the field is NULL, then a null value is inserted into the database.這是oracle 10g官方文檔關於direct的原文
      

  5.   

    看来direct=TRUE和default不能同时用了,郁闷