0

我正在尝试使用SQL loader将数据从 .dat 文件导入到 oracle 数据库中的表中。

控制文件:

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date(12) 'DD-MON-YYYY')

数据文件包含这样的记录:

5001,1001,7,Atlanta,01-FEB-2004

数据库中的表:

SQL> desc inventory.product_on_hand;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ON_HAND_ID                                NOT NULL NUMBER(5)
 PRODUCT_ID                                         NUMBER(7)
 QUANTITY                                           NUMBER(5)
 WAREHOUSE_CITY                                     VARCHAR2(30)
 LAST_UPDATE                                        DATE

我在 .log 文件中收到以下错误:

Record 1: Failed - Error in the table INVENTORY.PRODUCT_ON_HAND, column LAST_UPDATE.
ORA-01843: month not valid

请帮忙解决我的问题!

更新:

SQL> select sysdate from dual;

SYSDATE
-----------
06-OCT-2013

我设置了nls_lang='american'and nls_date_format='DD-MON-YYYY',但这没有帮助/

错误文件:

5001,1001,7,Atlanta,01-FEB-2004
5002,1001,7,Chicago,01-FEB-2004
5003,1001,7,Orlando,01-FEB-2004
5004,1002,7,Atlanta,01-FEB-2004
5005,1002,7,Chicago,01-FEB-2004
5006,1002,7,Orlando,01-FEB-2004
5007,1003,7,Atlanta,01-FEB-2004
5008,1003,7,Chicago,01-FEB-2004
5009,1003,7,Orlando,01-FEB-2004
5010,1004,7,Atlanta,01-FEB-2004
5011,1004,7,Chicago,01-FEB-2004
5012,1004,7,Orlando,01-FEB-2004
5013,1005,7,Atlanta,01-FEB-2004
5014,1005,7,Chicago,01-FEB-2004
5015,1005,7,Orlando,01-FEB-2004
5016,1006,7,Atlanta,01-FEB-2004
5017,1006,7,Chicago,01-FEB-2004
5018,1006,7,Orlando,01-FEB-2004
5019,1007,7,Chicago,01-FEB-2004
5020,1007,7,Orlando,01-FEB-2004
5021,1007,7,Atlanta,01-FEB-2004
5022,1008,7,Chicago,01-FEB-2004
5023,1008,7,Orlando,01-FEB-2004
5024,1008,7,Atlanta,01-FEB-2004
5025,1009,7,Chicago,01-FEB-2004
5026,1009,7,Orlando,01-FEB-2004
5027,1009,7,Atlanta,01-FEB-2004
5028,1010,7,Chicago,01-FEB-2004
5029,1010,7,Orlando,01-FEB-2004
5030,1010,7,Atlanta,01-FEB-2004
5031,1010,7,Chicago,01-FEB-2004
5032,1011,7,Orlando,01-FEB-2004
5033,1011,7,Atlanta,01-FEB-2004
5034,1012,7,Chicago,01-FEB-2004
5035,1012,7,Orlando,01-FEB-2004
5036,1012,7,Atlanta,01-FEB-2004
5037,1013,7,Chicago,01-FEB-2004
5038,1013,7,Orlando,01-FEB-2004
5039,1014,7,Atlanta,01-FEB-2004
5040,1014,7,Chicago,01-FEB-2004
5041,1015,7,Atlanta,01-FEB-2004
5042,1015,7,Chicago,01-FEB-2004
5043,1015,7,Orlando,01-FEB-2004
5044,1016,7,Atlanta,01-FEB-2004
5045,1016,7,Chicago,01-FEB-2004
5046,1016,7,Orlando,01-FEB-2004
5047,1017,7,Atlanta,01-FEB-2004
5048,1017,7,Chicago,01-FEB-2004
5049,1017,7,Orlando,01-FEB-2004
5050,1018,7,Atlanta,01-FEB-2004
5051,1018,7,Chicago,01-FEB-2004
4

2 回答 2

0

尝试

alter session set nls_date_language='american'; 

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date(12) 'DD-MON-YYYY')
于 2013-10-06T08:58:10.340 回答
0

问题是您在日期中指定了 12 个数字:last_update date(12) 'DD-MON-YYYY'在您的控制文件中,这是不正确的。

你应该把它当作last_update date 'DD-MON-YYYY'

SO 控制文件应为:

LOAD DATA
infile 'E:\labs\labs\lab_18_06.dat'
INTO TABLE INVENTORY.PRODUCT_ON_HAND
APPEND
FIELDS TERMINATED BY ','
(on_hand_id,
product_id,
quantity,
warehouse_city char(30),
last_update date 'DD-MON-YYYY')
于 2013-10-06T09:00:17.470 回答