我的数据是:
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:无效数字
怎么了?
答案 0 :(得分:1)
TYPE是一个oracle关键字,最好不要使用这样的列名。
表定义中没有TYPE列。如果列存在,则在读取所有字段后将常量赋值移动到控制文件的末尾。
STARTDTE“to_date(SUBSTR(:STARTDTE,1,10),'YYYY-MM-DD') - 27”, TYPE CONSTANT'FOOTBALL', 分数,
如果您尝试忽略将“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',
)
应该修正你得到的错误。