0

我的文件名 .dat 文件包含以下格式的 1000 条记录。

SIC_ID|NAME|CHANGED_DATE|LOGICALLY_DELETED
110|Wheat|31/10/2010 29:46:00|N

我要在其中提供内容的表还有几列。我希望将这些列留空,因为 .dat 文件中没有内容。表列:

SIC_ID, NAME, CREATED_USER_ID ,CREATED_DATE ,CHANGED_USER_ID ,CHANGED_DATE,LOGICALLY_DELETED,RECORD_VERSION

我的控制文件如下:-

    OPTIONS (DIRECT=TRUE,SKIP=1)
    LOAD DATA CHARACTERSET WE8MSWIN1252
    INFILE "mic_file.dat"
    BADFILE "sql/mic_file.bad"
    REPLACE
    INTO TABLE SDS_SIC
    FIELDS TERMINATED BY "|"
    TRAILING NULLCOLS
    (SIC_ID, NAME,
DATE "DD/MM/YYYY HH24:MI:SS" NULLIF (CHANGED_DATE=BLANKS),
LOGICALLY_DELETED)

运行 SQL*Loader 后,我看到以下错误:

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
SIC_ID                              FIRST     *   |       CHARACTER
NAME                                 NEXT     *   |       CHARACTER
CHANGED_DATE                         NEXT     *   |       CHARACTER
LOGICALLY_DELETED                    NEXT     *   |       CHARACTER

Record 1: Rejected - Error on table SDS_SIC, column CHANGED_DATE.
ORA-26041: DATETIME/INTERVAL datatype conversion error

最后两行错误被多次抛出。现在已修复:)

错误 2:LOGICALLY_DELETED 只有 2 个可能的值 - Y 或 N。

Record 51: Rejected - Error on table SDS_SIC, column LOGICALLY_DELETED.
ORA-12899: value too large for column LOGICALLY_DELETED (actual: 2, maximum: 1)

上述错误多次显示。

4

2 回答 2

2

Remember that the control file column list is in the order fields are in the data file. Data is matched to the table columns by name. Your control file has the 3rd and 4th fields mapped to FILLER, that's why they are blank. FILLER only applies to a field in the data file you don't want.

You need something like this only in your column list section, the TRAILING NULLCOLS will handle the rest of the columns of the table:

(SIC_ID, 
 NAME, 
 CHANGED_DATE  DATE "DD/MM/YYYY HH24:MI:SS" NULLIF (CHANGED_DATE=BLANKS),
 LOGICALLY_DELETED
)

See this recent post which happens to describe the relationship by giving an example: Skipping data fields while loading delimited data using SQLLDR

于 2015-04-30T13:37:55.370 回答
0

您可以转到 MySQL 命令行客户端并将值插入到所需的列中,您应该执行以下操作:就像您想要将值插入到

SIC_ID|NAME|CHANGED_DATE|LOGICALLY_DELETED

而不是在那些额外的列中。你应该输入:

insert into 'whatever the table name is'(SIC_ID,NAME,CHANGED_DATE,LOGICALLY_DELETED)
values(112,'wheat','31/10/2010 19:46:00',N);

仅在您已获取列的属性 varchar 的地方使用单引号尝试它....它会工作

于 2015-04-30T12:47:02.950 回答