文章详情

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

请输入下面的图形验证码

提交验证

短信预约提醒成功

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

2024-04-02 19:55

关注

目标:
将/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

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯