我正在尝试使用SQLLoader将csv数据加载到表中但是我收到以下错误 - 记录1:已拒绝 - 表PMI_DATA_SPRINT_REPORTER.PERSON上的错误,列DATETIME_OF_BIRTH。 ORA-00984:这里不允许列
由于只需要YYYY-MM-DD,尝试了subvstr和to_date数据 -
DATETIME_OF_BIRTH "TO_DATE(substr(DATETIME_OF_BIRTH,1,10),'YYYY-MM-DD')",
但收到了与上述相同的错误。
感谢任何建议,谢谢。
表格的DDL
CREATE TABLE "PERSON"
( "PERSON_ID" NUMBER(19,0),
"GENDER_CONCEPT_ID" NUMBER(19,0),
"YEAR_OF_BIRTH" NUMBER(19,0),
"MONTH_OF_BIRTH" NUMBER(19,0),
"DAY_OF_BIRTH" NUMBER(19,0),
"DATETIME_OF_BIRTH" DATE,
"RACE_CONCEPT_ID" NUMBER(19,0),
"ETHNICITY_CONCEPT_ID" NUMBER(19,0),
"LOCATION_ID" NUMBER(19,0),
"PROVIDER_ID" NUMBER(19,0),
"CARE_SITE_ID" NUMBER(19,0),
"PERSON_SOURCE_VALUE" VARCHAR2(500 CHAR),
"GENDER_SOURCE_VALUE" VARCHAR2(500 CHAR),
"GENDER_SOURCE_CONCEPT_ID" NUMBER(19,0),
"RACE_SOURCE_VALUE" VARCHAR2(500 CHAR),
"RACE_SOURCE_CONCEPT_ID" NUMBER(19,0),
"ETHNICITY_SOURCE_VALUE" VARCHAR2(500 CHAR),
"ETHNICITY_SOURCE_CONCEPT_ID" NUMBER(19,0)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 81920 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
ALTER TABLE "PERSON" MODIFY ("ETHNICITY_CONCEPT_ID" NOT NULL ENABLE);
ALTER TABLE "PERSON" MODIFY ("RACE_CONCEPT_ID" NOT NULL ENABLE);
ALTER TABLE "PERSON" MODIFY ("YEAR_OF_BIRTH" NOT NULL ENABLE);
ALTER TABLE "PERSON" MODIFY ("GENDER_CONCEPT_ID" NOT NULL ENABLE);
ALTER TABLE "PERSON" MODIFY ("PERSON_ID" NOT NULL ENABLE);
控制文件
load data
infile 'filename.csv' "str '\r\n'"
append
into table PERSON
fields terminated by ','
OPTIONALLY ENCLOSED BY '"' AND '"'
trailing nullcols
(
PERSON_ID integer,
GENDER_CONCEPT_ID integer,
YEAR_OF_BIRTH integer,
MONTH_OF_BIRTH integer,
DAY_OF_BIRTH integer,
DATETIME_OF_BIRTH DATE "YYYY-MM-DD",
RACE_CONCEPT_ID integer,
ETHNICITY_CONCEPT_ID integer,
LOCATION_ID integer,
PROVIDER_ID integer,
CARE_SITE_ID integer,
PERSON_SOURCE_VALUE CHAR(4000),
GENDER_SOURCE_VALUE CHAR(4000),
GENDER_SOURCE_CONCEPT_ID integer,
RACE_SOURCE_VALUE CHAR(4000),
RACE_SOURCE_CONCEPT_ID integer,
ETHNICITY_SOURCE_VALUE CHAR(4000),
ETHNICITY_SOURCE_CONCEPT_ID integer)
带有示例记录的CSV(不确定如何在此处放置实际文件..)
PERSON_ID GENDER_CONCEPT_ID YEAR_OF_BIRTH MONTH_OF_BIRTH DAY_OF_BIRTH DATETIME_OF_BIRTH RACE_CONCEPT_ID ETHNICITY_CONCEPT_ID LOCATION_ID PROVIDER_ID CARE_SITE_ID PERSON_SOURCE_VALUE GENDER_SOURCE_VALUE GENDER_SOURCE_CONCEPT_ID RACE_SOURCE_VALUE RACE_SOURCE_CONCEPT_ID ETHNICITY_SOURCE_VALUE ETHNICITY_SOURCE_CONCEPT_ID
1000003049 8532 1934 6 30 1934-06-30T00:00:00-05:00 8527 38003564 0 180930 0 1:FEMALE 44394 26:WHITE 47289 10:NOT HISPANIC OR LATINO 44331
答案 0 :(得分:2)
您需要使用单引号:
DATETIME_OF_BIRTH DATE 'YYYY-MM-DD',
答案 1 :(得分:0)
这样的事情有用吗?
这是控制文件中的一行:
DATETIME_OF_BIRTH "to_date(substr(trim(:datetime_of_birth), 1, instr(:datetime_of_birth, 'T') - 1), 'yyyy-mm-dd')" ,