Oracle Sqlldr optionally enclosed by

Oracle Sqlldr optionally enclosed by(GCH)

In all, when you edit the control file,you would rather add theclause “optionally enclosed by” inensurance.

The following example is that not use the clause “optionallyenclosed by”.

As follows, never use the clause “optionally enclosed by”in the control file.

OPTIONS(skip=1)

LOADDATA

INFILE"/home/oracle/sqlldr/MB_PERFORMANCE_TD_CELL.csv"

APPENDINTO TABLE MB_PERFORMANCE_TD_CELL

Fieldsterminated by ","

trailingnullcols

(EVENT_DAYtimestamp "yyyy-mm-dd hh24:mi:ss",

HOUR_P,

CITY_NAME,

COUNTRY_NAME,

VENDOR,

CELL_NAME,

CGI,

RLC_THRPUT ,

UTRAN1_NUM,

UTRAN2_NUM ,

RECORD_TIME"to_timestamp(to_char(sysdate,‘yyyymmdd hh24:mi:ss‘),‘yyyymmddhh24:mi:ss‘)",

VERSION_ID constant "3"

)

Next import data

[[email protected]]$ sqlldr daidai/love8013control=MB_PERFORMANCE_TD_CELL.CTL

SQL*Loader:Release 11.2.0.4.0 - Production on Tue Jun 14 22:35:52 2016

Copyright(c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Commitpoint reached - logical record count 64

Commitpoint reached - logical record count 128

Commitpoint reached - logical record count 192

Commitpoint reached - logical record count 256

Commitpoint reached - logical record count 320

Commitpoint reached - logical record count 384

Commitpoint reached - logical record count 448

Commitpoint reached - logical record count 512

Commitpoint reached - logical record count 576

Commitpoint reached - logical record count 640

Commitpoint reached - logical record count 704

Commitpoint reached - logical record count 768

Commitpoint reached - logical record count 832

Commitpoint reached - logical record count 896

Commitpoint reached - logical record count 960

Commitpoint reached - logical record count 1024

Diagnose

Scan import log

……

Record96: Rejected - Error on table MB_PERFORMANCE_TD_CELL, column UTRAN2_NUM.

ORA-01722:invalid number

Record119: Rejected - Error on table MB_PERFORMANCE_TD_CELL, column UTRAN2_NUM.

ORA-01722:invalid number

Record126: Rejected - Error on table MB_PERFORMANCE_TD_CELL, column UTRAN2_NUM.

ORA-01722:invalid number

…….

From the import log, it is the conclusionthat some were imported successfully. I select from database. Samples are asfollows:

Therefore, the columns in the control filecorrespond to th

e columns of goal table. However, there were still a fewrecords that were not imported into table.

Scan bad record.

[[email protected]]$ cat MB_PERFORMANCE_TD_CELL.bad

2016-06-0700:00:00,,达州,渠县,华为,SDZ6NR5:渠县涌兴_2,460-00-61844-12098,,,

2016-06-0700:00:00,,内江,内江归属未知,华为,SNJ6NR2DX:田家十中_1,460-00-61811-34907,,,

2016-06-0700:00:00,,资阳,资阳归属未知,华为,SZY6NR3:乐至大佛二站_1,460-00-61889-40577,,,

2016-06-0700:00:00,,资阳,资阳归属未知,华为,SZY4NR3:乐至仲良中学_1,460-00-61889-35687,,,

2016-06-0700:00:00,,内江,内江归属未知,华为,SNJ5NR5WY:城北_3,460-00-61812-36239,,,

2016-06-0700:00:00,,达州,宣汉县,华为,SDZ6NR3:宣汉普光105_1,460-00-61841-24707,,,

2016-06-0700:00:00,,达州,渠县,华为,SDZ6NR5:渠县望江庭_1,460-00-61844-60867,,,

Then, I think of keyword ‘optionallyenclosed by’.

Solve the proplem.

Modify the control file.

cat MB_PERFORMANCE_TD_CELL.CTL

OPTIONS(skip=1)

LOAD DATA

INFILE"/home/oracle/sqlldr/MB_PERFORMANCE_TD_CELL.csv"

APPEND INTO TABLE MB_PERFORMANCE_TD_CELL

Fields terminated by "," optionlly enclosed by " "

trailing nullcols

(EVENT_DAY timestamp "yyyy-mm-ddhh24:mi:ss",

HOUR_P,

CITY_NAME,

COUNTRY_NAME,

VENDOR,

CELL_NAME,

CGI,

RLC_THRPUT ,

UTRAN1_NUM,

UTRAN2_NUM ,

RECORD_TIME"to_timestamp(to_char(sysdate,‘yyyymmdd hh24:mi:ss‘),‘yyyymmddhh24:mi:ss‘)",

VERSION_ID constant "3"

)

Import data successfully.

SQL> select count(*) fromMB_PERFORMANCE_TD_CELL

2  ;

COUNT(*)

----------

50908

时间: 2024-10-07 22:28:18

Oracle Sqlldr optionally enclosed by的相关文章

Oracle sqlldr命令

今天别人的入库代码,看的真有点晕,最后看完才知道是用了sqlldr命令.哎...还是学艺不精啊,今后还是要多努力. 总结哈sqlldr命令:虽然大多是网上来的,自己要有体会嘛 !开源就是好啊. sqlldr是cmd下的命令,用来将文本格式数据导入到数据库中. 命令格式: sqlldr username/[email protected] control=*.ctl *.ctl格式为: load data infile "d://test.txt"    外部数据文件 infile &q

Oracle sqlldr 应用

我们可以用Oracle的sqlldr工具来导入数据,着重关注以下几个参数: userid -- Oracle 的 username/password[@servicename]control -- 控制文件,可能包含表的数据log -- 记录导入时的日志文件,默认为 控制文件(去除扩展名).logbad -- 坏数据文件,默认为 控制文件(去除扩展名).baddata -- 数据文件,一般在控制文件中指定.用参数控制文件中不指定数据文件更适于自动操作errors -- 允许的错误记录数,可以用他

oracle sqlldr使用(导入速度快,但对数据本身的处理功能弱)

oracle sqlldr使用(导入速度快,但对数据本身的处理功能弱) 博客分类: DB.Oracle OracleSQL sqlload.cmd Sql代码   pause sqlldr user/[email protected] control.ctl skip=1 rows=2000 bindsize=8192000 pause control.ctl Sql代码   LOAD DATA INFILE 'Rating201001.csv' APPEND INTO TABLE "TBL_S

Oracle sqlldr导入之“MAXIMUM ERROR COUNT EXCEEDED”

昨天看到一个同事在通过PL/SQL Developer工具把文本数据往oracle表;有两个文本:一个有30万条记录:一个7万多条记录.在导入到过程中:出现错误记录还需要点击确认.不过使用黑科技(屏幕精灵)自动点击.单一个7万多记录的文本需要10分钟左右的时间. 看到这种情况:我热心肠爆发:我帮你来提快导入速度.我想到两种方案:    1:oracle的sqlldr命令    2:oracle的外部表:    由于文本存在错误记录:就选择1.    文本格式如下:存在有76760条记录 [[em

Oracle sqlldr使用示例

SQLLDR用于快速的批量导入数据, 示例步骤如下: 1.确定Oracle的连接示例 username/[email protected] 我使用的是:system/world @ localorcl sid是连接的示例,也就是net manager中的服务命名,示意图如下: 2.创建表,语句如下: CREATE TABLE TT ( ID INTEGER, NAME VARCHAR2(20 BYTE), CON VARCHAR2(20 BYTE), DT DATE ) 3.在D盘下创建数据文件

Oracle sqlldr导入导出txt数据文件详解

一.sqlldr导入txt 1.预备 a).txt文件 这里要保存成无签名的UTF-8 b).oracle建表 2.编写控制文件input_test.ctl LOAD DATA CHARACTERSET 'UTF8' --字符集设定 INFILE 'd:\input_test.txt' --要导入的文本数据路径,可写多个REPLACE into TABLE input_test --清空原有数据再导入方式 追加导入 用append into table t_namefields terminat

oracle sqlldr导入数据

背景 900W数据的TXT文本,文件内容各字段以"|"分隔,使用nevicat导入太慢 解决办法 使用sqlldr导入数据, 1)建立配置文件test.ctl [[email protected] ~]$ cat test.ctlload datainfile 'data.txt' into table CMCCfields terminated by "|"(id,phone,service_id,time,cmcc_num,cmcc_s) 解释:data.txt

ORACLE SQLLDR导入

最近由于需要造很多相似的数据,所以研究了一下Sqlloader这个工具. 这个工具对于大量的数据插入有很大帮助. 具体用法: 常使用的关键字: userid   --   ORACLE   username/password     control   --   Control   file   name     log   --   Log   file   name     bad   --   Bad   file   name     data   --   Data   file  

sqlldr导入数据(以PostgreSql>>>Oracle为例)

1.在目标数据库中创建表 1.1点击源表,复制创建语句 1.2 修改数据类型以匹配目标数据库,如: 字符串类型:character varying(20)>>>varchar2(20) 数字类型:numeric(19,2)>>>number(19,2) 时间戳:timestamp without time zone>>>timestamp或date 1.3 其他 一般字符串类型需要加长长度,不然有时会插不进去数据,不知为什么: P和O数据库的not n