sql load 数据未导入,报Commit point reached - logical record count 64
1.创建表,并准备好文件a11_test1.csv
SQL> create table a11_test1
2 (site_name varchar2(100),
3 well_common_name varchar2(100));
Table created.
2.创建控制文件
[oracle@oeltan1 a11]$ vi a11load.ctl
load data
infile '/u01/a11/a11_test1.csv'
append into table a11_test1
fields terminated by ","
(WELL_COMMON_NAME,SITE_NAME)
这儿注意列的顺序不能乱了
3. 导入
问题1:权限不够
[oracle@oeltan1 a11]$ sqlldr userid=scott/scott control=a11load.ctl
SQL*Loader: Release 11.2.0.3.0 - Production on Wed Jun 5 09:28:04 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 64
只出现上面一行说明导入没有成功。
查看日志:a11load.log
Record 51: Rejected - Error on table A11_TEST1.
ORA-01950: no privileges on tablespace 'USERS'
解决:
SQL> alter user scott quota 100m on users;
或者可以:
grant resource to scott;
再次导入
[oracle@oeltan1 a11]$ sqlldr userid=scott/scott control=a11load.ctl
SQL*Loader: Release 11.2.0.3.0 - Production on Wed Jun 5 09:39:55 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 64
Commit point reached - logical record count 128
Commit point reached - logical record count 192
Commit point reached - logical record count 256
Commit point reached - logical record count 320
Commit point reached - logical record count 322
经检查成功导入
问题2:时间格式需要特别指定
Record 19: Rejected - Error on table TAN_OIL, column CREATE_TIME.
ORA-01861: literal does not match format string
Record 20: Rejected - Error on table TAN_OIL, column CREATE_TIME.
[oracle@dev-1 sqlload]$ more oil.ctl
oil.csv文件中的时间格式是这样:
2009/1/15
数据库中的time类型为date
控制文件中时间类型列加date,并加格式:
…………
fields terminated by ","
(WELL_ID,ORG_name,
CREATE_TIME date "yyyy/mm/dd",
………………
问题3:最后列可能会多识别字符串
Record 9: Rejected - Error on table TAN_OIL, column WATER_PROD_DAILY.
ORA-01722: invalid number
Record 10: Rejected - Error on table TAN_OIL, column WATER_PROD_DAILY.
ORA-01722: invalid number
该字段在文本文件的最行一行,且是数据型的,从windows到linux之后后面多了个空格,linux将之识别为字符串,所以无法导入。
解决办法1:修改表的列为字符串格式
方法2:在文本文件的最后添加个逗号。