我的编程空间,编程开发者的网络收藏夹
学习永远不晚

oracle sqlloader导入时报ORA-01830解决过程

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

oracle sqlloader导入时报ORA-01830解决过程

目标:
将/home/oracle/xfsqlldr.csv导入到新建的CHOICE.T_LOAN_ANNUAL_CUSTNO表中。

新建表:
create table CHOICE.T_LOAN_ANNUAL_CUSTNO(
LOANNO VARCHAR2(200)  ,
FUNDCUSTNO VARCHAR2(200)  ,
DATEDATE DATE  ,
DATETYPE VARCHAR2(2)  ,
IS_DEL  VARCHAR2(1) DEFAULT '0' not null,
OITIME DATE DEFAULT sysdate not null,
OUTIME DATE DEFAULT sysdate not null); 处理文本,将标题行去掉
sed -i '1d' xfsqlldr.csv
more xfsqlldr.csv |wc -l
37291

编辑sqlloader控制文件
vi /home/oracle/xfsqlldr.ctl

load data
infile '/home/oracle/xfsqlldr.csv'
insert into table choice.T_LOAN_ANNUAL_CUSTNO
fields terminated by ','
OPTIONALLY ENCLOSED BY '"'
(    
    LOANNO,
    FUNDCUSTNO,
    DATEDATE,
    DATETYPE
) sqlloader导入:
sqlldr "'/as sysdba'" ROWS=10000 control=/home/oracle/xfsqlldr.ctl LOG=/home/oracle/xfsqlldr.log   

报错:
value used for ROWS parameter changed from 10000 to 248
Record 1: Rejected - Error on table CHOICE.T_LOAN_ANNUAL_CUSTNO, column DATEDATE.
ORA-01830: date format picture ends before converting entire input string

Record 2: Rejected - Error on table CHOICE.T_LOAN_ANNUAL_CUSTNO, column DATEDATE.
ORA-01830: date format picture ends before converting entire input string

Record 3: Rejected - Error on table CHOICE.T_LOAN_ANNUAL_CUSTNO, column DATEDATE.
ORA-01830: date format picture ends before converting entire input string

Record 4: Rejected - Error on table CHOICE.T_LOAN_ANNUAL_CUSTNO, column DATEDATE.
ORA-01830: date format picture ends before converting entire input string

Record 5: Rejected - Error on table CHOICE.T_LOAN_ANNUAL_CUSTNO, column DATEDATE.
ORA-01830: date format picture ends before converting entire input string

导入的时间列是如下格式:
2017/9/1 16:31:25.202000
秒后面的202000不能识别。

修改导入控制文件:
load data
infile '/home/oracle/xfsqlldr.csv'
insert into table CHOICE.T_LOAN_ANNUAL_CUSTNO
fields terminated by ','
OPTIONALLY ENCLOSED BY '"'
(    
    LOANNO,
    FUNDCUSTNO,
    DATEDATE "to_date(substr(:DATEDATE,'0',instr(:DATEDATE,'.')-1),'yyyy-mm-dd hh34:mi:ss')",
    DATETYPE
)

select to_date(substr('2017/9/1 16:31:25.202000','0',instr('2017/9/1 16:31:25.202000','.')-1),'yyyy-mm-dd hh34:mi:ss') from dual; sqlloader再次导入:
sqlldr "'/as sysdba'" ROWS=10000 control=/home/oracle/xfsqlldr.ctl LOG=/home/oracle/xfsqlldr.log   
省略大部分输出:
Commit point reached - logical record count 37044
Commit point reached - logical record count 37292
Commit point reached - logical record count 37540
Commit point reached - logical record count 37788
Commit point reached - logical record count 37921

检查日志:
Table CHOICE.T_LOAN_ANNUAL_CUSTNO:
  37921 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null. Space allocated for bind array:                 255936 bytes(248 rows)
Read   buffer bytes: 1048576

Total logical records skipped:          0
Total logical records read:         37921
Total logical records rejected:         0
Total logical records discarded:        0

检查数据:
SQL> select count(*) from CHOICE.T_LOAN_ANNUAL_CUSTNO;

  COUNT(*)
----------
     37921
总行数对。
select count(LOANNO) from CHOICE.T_LOAN_ANNUAL_CUSTNO    ;
COUNT(LOANNO)
-------------
        33466
sed -n '33465,33467p' xfsqlldr.csv
4106ed46b9de9370c001448a308881f1,4fdcf2ce524942b0a003757a615db4e9,2017/12/12 12:27:25.367000,2
a83c402de3c3233f7416884be2e2533c,290112dd17ca492184e13475f9b93817,2017/12/8 23:19:16.387000,2
,1b78c7f7e04b46a19b0973fad39143f6,2018/5/15 21:13:38.867000,3
select count(FUNDCUSTNO) from CHOICE.T_LOAN_ANNUAL_CUSTNO    ;        

COUNT(FUNDCUSTNO)
-----------------
            37921
该列没有空值,和总行数一致,正确。
select count(DATEDATE) from CHOICE.T_LOAN_ANNUAL_CUSTNO    ;
COUNT(DATEDATE)
---------------
          36453
sed -n '36452,36454p' xfsqlldr.csv
,8ea4d98b4825490c9c48a82307269175,2018/6/5 18:03:34.680643,3
,2e4cc6b253f6434e9a0a010513256022,2018/4/9 11:51:54.507954,3
,86f77fb6962943a78c00fd028bcdcaef,,4
正确。
SQL> select count(DATETYPE) from CHOICE.T_LOAN_ANNUAL_CUSTNO      ;

COUNT(DATETYPE)
---------------
          37921
该列没有空值,和总行数一致,正确。

赋权:
SELECT ROLE FROM DBA_ROLES WHERE ROLE LIKE '%CHOICE%';
grant select on CHOICE.T_LOAN_ANNUAL_CUSTNO to R_CHOICE_READER;
grant select on CHOICE.T_LOAN_ANNUAL_HISHOLD to R_CHOICE_READER;
grant R_CHOICE_READER to p_chenzy_r,p_xufang_r;
grant insert,update,delete on CHOICE.T_LOAN_ANNUAL_CUSTNO  to p_xufang_r;
grant insert,update,delete on CHOICE.T_LOAN_ANNUAL_HISHOLD to p_xufang_r;

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

oracle sqlloader导入时报ORA-01830解决过程

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

数据库导入导出时报ORA-01843的问题怎么解决

这篇文章主要介绍“数据库导入导出时报ORA-01843的问题怎么解决”,在日常操作中,相信很多人在数据库导入导出时报ORA-01843的问题怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”数据库导入导出
2023-06-03

编程热搜

目录