Oracle sqlldr导入之“MAXIMUM ERROR COUNT EXCEEDED”
昨天看到一个同事在通过PL/SQL Developer工具把文本数据往oracle表;有两个文本;一个有30万条记录;一个7万多条记录。
在导入到过程中;出现错误记录还需要点击确认。不过使用黑科技(屏幕精灵)自动点击。单一个7万多记录的文本需要10分钟左右的时间。
看到这种情况;我热心肠爆发;我帮你来提快导入速度。我想到两种方案;
1:oracle的sqlldr命令
2:oracle的外部表;
由于文本存在错误记录;就选择1.
文本格式如下:存在有76760条记录
[oracle@oracle234 ~]$ wc -l lottu.txt
76761 lottu.txt
[oracle@oracle234 ~]$ head lottu.txt
stat_user_stay_info.rowkey,stat_user_stay_info.appkey,stat_user_stay_info.phone_softversion,stat_user_stay_info.dim_type,stat_user_stay_info.dim_code,stat_user_stay_info.time_peroid,stat_user_stay_info.stat_date,stat_user_stay_info.indicator,stat_user_stay_info.stat_time,stat_user_stay_info.value
3a00997_7c34d20170108,307A5C626E6C2F6472636E6E6A2F736460656473,2.14.0,cpid,blf1298_12243_001,1,20170105,stay3day,20170109102339,1
3a00997_bf86b20170108,307A5C626E6C2F6472636E6E6A2F736460656473,2.13.0,cpid,blp1375_13621_001,1,20170105,stay3day,20170109102339,7
3a00e87_4b11a20170126,337A5C626E6C2F6472636E6E6A2F736460656473,1.4.0,cpid,all,1,20170123,stay3day,20170127095931,6
3a0129a_6575220170118,307A5C626E6C2F6460726E742F716D7472,all,cpid,bsf1389_10917_001,1,20170116,stay2day,20170119094145,1
3a0183b_5764a20170202,307A5C626E6C2F6472636E6E6A2F736460656473,1.91,cpid,blf1298_12523_001,1,20170128,stay5day,20170203094327,1
3a01b9b_54b4720170123,307A5C626E6C2F6472636E6E6A2F736460656473,2.13.0,cpid,blp1375_13641_001,1,20170122,stay1day,20170124102457,3
3a0230d_7464120170126,307A5C626E6C2F6460726E742F606F65736E686569646D716473,all,cpid,bsp1405_13363_001,1,20170122,stay4day,20170127100446,18
3a02bed_3ea3320170206,307A5C626E6C2F6472636E6E6A2F736460656473,2.15.0,cpid,blp1375_14217_001,1,20170130,stay7day,20170207135438,1
3a03fe3_4c5fe20170119,307A5C21626E6C2F6472776865646E21,all,cpid,bvf1328_10885_001,1,20170116,stay3day,20170120093733,1
导入表结果如下:
SQL> desc STAT_USER_STAY_INFO1;
Name Null? Type
----------------------------------------- -------- ----------------------------
JOBID VARCHAR2(64)
APPKEY NOT NULL VARCHAR2(200)
PHONE_SOFTVERSION NOT NULL VARCHAR2(32)
DIM_TYPE NOT NULL VARCHAR2(64)
DIM_CODE NOT NULL VARCHAR2(64)
TIME_PEROID NOT NULL VARCHAR2(4)
STAT_DATE NOT NULL VARCHAR2(500)
INDICATOR NOT NULL VARCHAR2(200)
STAT_TIME VARCHAR2(500)
VALUE NOT NULL NUMBER
执行sqlldr命令;但结果呢?只导入5万条记录;结果出乎意料。
sqlldr 'lottu/li0924' control=/home/oracle/stay_info.ctl log=/home/oracle/stay_info.log bad=/home/oracle/stay_info.bad
查看log文件;由于篇幅的问题;只取关键部分。
.......
Record 55076: Rejected - Error on table STAT_USER_STAY_INFO1, column DIM_CODE.
ORA-01400: cannot insert NULL into ("LOTTU"."STAT_USER_STAY_INFO1"."DIM_CODE") MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run. Table STAT_USER_STAY_INFO1:
55025 Rows successfully loaded.
51 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: 165120 bytes(64 rows)
Read buffer bytes: 1048576 Total logical records skipped: 0
Total logical records read: 55105
Total logical records rejected: 51
Total logical records discarded: 0 Run began on Fri Feb 24 10:51:02 2017
Run ended on Fri Feb 24 10:51:09 2017 Elapsed time was: 00:00:06.87
CPU time was: 00:00:00.46
日志提示;只导入了“55025 Rows successfully loaded. ”;加上拒绝的51条;这跟76761条记录远远不够。
日志记录是不会骗人的;进入表中查看确实是55025条记录
SQL> select count(*) from STAT_USER_STAY_INFO1; COUNT(*)
----------
55025
奇了怪;明明76761条记录;为什么oracle只认可5万条记录 。还有2万多条记录为什么不认可呢?
其实oracle给了提示;就在刚刚那个log文件中。只是我忽略这样一句话"MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run."。
这个意思是说;超过最大所容限错误数。
既然说得这么清楚了;我们在看看sqlldr命令
[oracle@oracle234 ~]$ sqlldr
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Feb 24 11:00:08 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Usage: SQLLDR keyword=value [,keyword=value,...]
Valid Keywords:
userid -- ORACLE username/password
control -- control file name
log -- log file name
bad -- bad file name
data -- data file name
discard -- discard file name
discardmax -- number of discards to allow (Default all)
skip -- number of logical records to skip (Default 0)
load -- number of logical records to load (Default all)
errors -- number of errors to allow (Default 50)
rows -- number of rows in conventional path bind array or between direct path data saves
(Default: Conventional path 64, Direct path all)
bindsize -- size of conventional path bind array in bytes (Default 256000)
silent -- suppress messages during run (header,feedback,errors,discards,partitions)
direct -- use direct path (Default FALSE)
parfile -- parameter file: name of file that contains parameter specifications
parallel -- do parallel load (Default FALSE)
file -- file to allocate extents from
skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
readsize -- size of read buffer (Default 1048576)
external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE (Default NOT_USED)
columnarrayrows -- number of rows for direct path column array (Default 5000)
streamsize -- size of direct path stream buffer in bytes (Default 256000)
multithreading -- use multithreading in direct path
resumable -- enable or disable resumable for current session (Default FALSE)
resumable_name -- text string to help identify resumable statement
resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
date_cache -- size (in entries) of date conversion cache (Default 1000)
no_index_errors -- abort load on any index errors (Default FALSE)
PLEASE NOTE: Command-line parameters may be specified either by
position or by keywords. An example of the former case is 'sqlldr
scott/tiger foo'; an example of the latter is 'sqlldr control=foo
userid=scott/tiger'. One may specify parameters by position before
but not after parameters specified by keywords. For example,
'sqlldr scott/tiger control=foo logfile=log' is allowed, but
'sqlldr scott/tiger control=foo log' is not, even though the
position of the parameter 'log' is correct.
其中有一行内容“ errors -- number of errors to allow (Default 50)”
所以说上面出现问题就不奇怪了。
最后将sqlldr命令加errors参数即可。
sqlldr 'lottu/li0924' control=/home/oracle/stay_info.ctl log=/home/oracle/stay_info.log bad=/home/oracle/stay_info.bad errors=1000
整个过程20秒处理完成。相比之下;我那同事果断选择这种方法。
Oracle sqlldr导入之“MAXIMUM ERROR COUNT EXCEEDED”的更多相关文章
- Oracle sqlldr导入导出txt数据文件详解
一.sqlldr导入txt 1.预备 a).txt文件 这里要保存成无签名的UTF-8 b).oracle建表 2.编写控制文件input_test.ctl LOAD DATA CHARACTERSE ...
- oracle sqlldr导入数据和导入去除空格
1.新建目录E:\load把需要导入的数据文件放到目录下面 这是我自己造的测试数据... 2.在文件下新建脚本文件 Load data infile 'E:\load\info.txt' into t ...
- [转]sqlldr 导入乱码,Oracle客户端字符集问题
1,查Oracle数据库创建时候的字符集:oracle服务器端执行 SQL> select name, value$ from sys.props$ where name like 'NLS%' ...
- Oracle数据库导入csv文件(sqlldr命令行)
1.说明 Oracle数据库导入csv文件, 当csv文件较小时, 可以使用数据库管理工具, 比如DBevaer导入到数据库, 当csv文件很大时, 可以使用Oracle提供的sqlldr命令行工具, ...
- oracle sqlldr使用(导入速度快,但对数据本身的处理功能弱)
oracle sqlldr使用(导入速度快,但对数据本身的处理功能弱) 博客分类: DB.Oracle OracleSQL sqlload.cmd pause sqlldr user/pass@tn ...
- Oracle 数据库导入与出
Oracle 数据库导入与出 导出( EXPORT )是用 EXP 将数据库部分或全对象的结构和导出 . 导入( 导入( IMPORT )是用 )是用 IMP IMP将 OS 文件中的对象结构和数据装 ...
- Oracle IMPDP导入数据案例之注意事项(undo/temp)
针对Oracle数据迁移,我们可能会用到expdp/impdp的方式,有时候需要大表.lob字段等可能会消耗过大的临时表空间和undo表空间,所以一般我们根据导出日志,在导入前适当调整表空间大小.否则 ...
- Oracle sqlldr数据加载
1 sqlldr 传统路径:sqlldr会利用sql插入为我们加载数据 直接路径加载:sqlldr不适用sql,直接格式化数据块,绕开undo,避开redo,最快的方法就是并行直接路径加载 sqlld ...
- Oracle impdp导入数据临时表空间与undo表空间爆满解决实例
Oracle impdp导入数据临时表空间与undo表空间爆满解决实例 [日期:2018-01-24] 来源:Linux社区 作者:rangle [字体:大 中 小] 针对Oracle数据迁移, ...
随机推荐
- easyui使用介绍
http://www.jeasyui.com/index.php based on jQuery, Angular and Vue. don't need to write many javascri ...
- Java设计模式(7)装饰模式(Decorator模式)
Decorator常被翻译成"装饰",我觉得翻译成"油漆工"更形象点,油漆工(decorator)是用来刷油漆的,那么被刷油漆的对象我们称decoratee.这 ...
- R语言:读取数据
主要学习如何把几种常用的数据格式导入到R中进行处理,并简单介绍如何把R中的数据保存为R数据格式和csv文件. 1.保存和加载R的数据(与R.data的交互:save()函数和load()函数)a &l ...
- R语言:变量名称和字符串的转换
R语言:变量名称和字符串的转换 2014-06-23 14:45:27 在R语言中,经常会遇到变量名称和字符串相互转换的问题.比如说,进行1000次循环运算,并将运算结果存储在1000 ...
- 关于go语言的环境配置 SDK+path+工作目录
第一步: 安装Golang的SDK http://golang.org,下载最新的安装包,之后双击安装即可. 安装完成之后,打开终端,输入go.或者go version(查看安装版本)出现如下信息即表 ...
- 3D引擎Axiom的选择与学习.
经过前面针对OpenGL的一些特性的学习,越发觉得要学的更多,相关如LOD,各种阴影实现,场景管理如BSP与Octree等以及还没听过的各种的实现.有感自学的进度太慢,并且在做一些小DEMO时,心中不 ...
- 访问网站出现EOF
HTTP/0.0 503 Service Unavailable Date: Tuesday, 18-Apr-17 10:29:46 CST Keep-Alive: timeout=38 EOF 今天 ...
- ping失败的结果分析
①Request timed out 这是大家经常碰到的提示信息,很多文章中说这是对方机器置了过滤ICMP数据包,从上面工作过程来看,这是不完全正确的,至少有下几种情况. a. 对方已关机,或者网络上 ...
- 如何找回Ucenter创始人密码,账号无需修改
UCenter 创始人的密码非常重要,忘记或丢失后,就不能进入 UCenter 进行用户和数据的管理,也会对站点造成安全隐患.由于 UCenter 的密码是采用两次 md5 加一个随机数的形式加密的, ...
- mysql的字符串函数
From: http://www.cnblogs.com/xiaochaohuashengmi/archive/2010/12/13/1904330.html 对于针对字符串位置的操作,第一个位置被标 ...