1

我的数据是这样的:

ID,SCORE_DATE,TYPE,SCORE,RAW_SCORE,RANK
A1234,2012-09-05 23:59:59,FOOTBALL_TEAM_MIDDLE_AND_OLD_1234,10,0.123,1
A5678,2012-09-05 23:59:59,FOOTBALL_TEAM_MIDDLE_AND_OLD_1234,20,0.456,2

CTL 文件:

load data           
infile 'E:\Data\Sample.csv'
badfile 'E:\Data\Sample.bad'
APPEND into table TABLE1    
fields terminated by "," optionally enclosed by '"'
TRAILING NULLCOLS               
(   
 DRIVER,
 STARTDTE "to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD') - 27",
 TYPE  CONSTANT 'FOOTBALL',
 SCORE   ,
 RANKSCORE ":SCORE",
 RANK    ,
 ENDDTE "to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD')",
 LOADDT     "sysdate"
)

这是我的表结构:

CREATE TABLE "TABLE1"
  (
    "DRIVER" VARCHAR2(50 BYTE),
    "STARTDTE" DATE,
    "SCORE"           NUMBER,
    "ENDDTE" DATE,
    "TYPE" VARCHAR2(20 BYTE),
    "RANK"       NUMBER,
    "RANKSCORE"  NUMBER,
    "LOADDT"     VARCHAR2(20 BYTE)
  );

对于加载的每一行,我都会收到一条错误消息:记录 3:拒绝 - 表 TABLE1 列 SCORE 上的错误。ORA-01722: 无效号码

怎么了?

4

1 回答 1

1
  1. TYPE 是一个 oracle 关键字,最好不要使用这样的列名。

  2. 表定义中没有 TYPE 列。如果该列存在,则在读取所有字段后,将常量赋值移动到控制文件的末尾。

    STARTDTE "to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD') - 27", TYPE CONSTANT 'FOOTBALL', SCORE ,

如果您试图忽略具有“FOOTBALL_TEAM_MIDDLE_AND_OLD_1234”作为数据的字段,则需要添加

THIRD_COLUMN FILLER,

到您的控制文件以忽略该数据。就像是..

load data           
infile 'E:\Data\Sample.csv'
badfile 'E:\Data\Sample.bad'
APPEND into table TABLE1    
fields terminated by "," optionally enclosed by '"'
TRAILING NULLCOLS               
(   
 DRIVER,
 STARTDTE "to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD') - 27",
 THIRD_COLUMN FILLER,
 SCORE   ,
 RANKSCORE ":SCORE",
 RANK    ,
 ENDDTE "to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD')",
 LOADDT     "sysdate"
 TYPE  CONSTANT 'FOOTBALL',
)

应该解决您遇到的错误。

于 2012-09-21T20:03:40.567 回答