ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SQLLOADER 16 导入大量文本

SQLLOADER 16 导入大量文本

原创 Linux操作系统 作者:ilsyx 时间:2012-08-07 21:11:13 0 删除 编辑

一 描述

此档是sqlloader学习的第16篇,目的在flat源数据文件中引用外部其他数据文件加载数据到数据库.

二 操作环境

OS info

windows server 2003 32bit

DB info

连接到:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production

SQL> set lines 150
SQL> COL PRODUCT FORMAT A55
SQL> COL VERSION FORMAT A15
SQL> COL STATUS FORMAT A15
SQL> SELECT * FROM PRODUCT_COMPONENT_VERSION;

PRODUCT                                                 VERSION         STATUS
------------------------------------------------------- --------------- ---------------
NLSRTL                                                  9.0.1.1.1       Production
Oracle9i Enterprise Edition                             9.0.1.1.1       Production
PL/SQL                                                  9.0.1.1.1       Production
TNS for 32-bit Windows:                                 9.0.1.1.0       Production

SQL>

other

脚本目录:C:\sqlloader_exec\ppt_case13

三 过程设计

1.准备的flat源数据testLoad_clob.csv
1,one row,1901-01-01,note1.txt
2,two row,1902-01-01,note2.txt
3,three row,1903-01-01,note3.txt
4,four row,1904-01-01,note4.txt
5,five row,1905-01-01,note5.txt
6,six row,1906-01-01,note6.txt
7,serven row,1907-01-01,note7.txt
8,eight row,1908-01-01,note8.txt
9,nine row,1909-01-01,note9.txt

(注:note*.txt中的内容可自己随便添加)

2.相关文件testLoad_clob.sql
rem
rem
rem

set termout off

drop table testLoad_clob;
create table testLoad_clob (f1 number,f2 varchar2(30),f3 date,f4 clob);
exit;

3.相关文件testLoad_clob.ctl
LOAD DATA
        INFILE 'testLoad_clob.csv'
        BADFILE 'testLoad_clob'                -- 无法插入的记录被放入该文件中
        APPEND
        INTO TABLE testLoad_clob
        TRAILING NULLCOLS
        (
                F1        INTEGER EXTERNAL TERMINATED BY ",",
                F2        CHAR TERMINATED BY ",",
                F3        DATE "RRRR-MM-DD" TERMINATED BY ",",
                F4_file_name FILLER CHAR TERMINATED BY ",",
                F4        LOBFILE(F4_file_name)
                        TERMINATED BY EOF
        )

4.以scott用户登录数据库运行testLoad_clob.sql初始化环境.
5.在cmd命令下执行sqlldr加载testLoad_clob.ctl控制文件命令
6.查看sqlldr日志信息
7.查看sqlldr bad日志信息
8.查看数据库加载成功的数据

四 详细步骤操作

1.以scott用户登录数据库运行testLoad_clob.sql初始化环境.
C:\sqlloader_exec\ppt_case13>sqlplus "scott/tiger"

SQL*Plus: Release 9.0.1.0.1 - Production on 星期二 8月 7 21:39:47 2012

(c) Copyright 2001 Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production

SQL> @testLoad_clob
从Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production中断开

C:\sqlloader_exec\ppt_case13>

2.在cmd命令下执行sqlldr加载testLoad_clob.ctl控制文件命令
C:\sqlloader_exec\ppt_case13>sqlldr "scott/tiger" control=testLoad_clob.ctl

SQL*Loader: Release 9.0.1.1.1 - Production on 星期二 8月 7 21:40:31 2012

(c) Copyright 2001 Oracle Corporation.  All rights reserved.

达到提交点,逻辑记录计数8
达到提交点,逻辑记录计数9

C:\sqlloader_exec\ppt_case13>

3.查看sqlldr日志信息

SQL*Loader: Release 9.0.1.1.1 - Production on 星期二 8月 7 21:40:31 2012

(c) Copyright 2001 Oracle Corporation.  All rights reserved.

控制文件: testLoad_clob.ctl
数据文件: testLoad_clob.csv
错误文件: testLoad_clob.bad
废弃文件: 未作指定
:
(可废弃所有记录)

加载数: ALL
跳过数: 0
允许的错误: 50
绑定数组: 64 行,最大 256000 字节
继续:    未作指定
所用路径:       常规

表TESTLOAD_CLOB
已加载从每个逻辑记录
插入选项对此表APPEND生效
TRAILING NULLCOLS 选项生效

   列名                        位置      长度  中止 包装数据类型
------------------------------ ---------- ----- ---- ---- ---------------------
F1                                  FIRST     *    ,      CHARACTER           
F2                                   NEXT     *    ,      CHARACTER           
F3                                   NEXT     *    ,      DATE RRRR-MM-DD     
F4_FILE_NAME                         NEXT     *    ,      CHARACTER           
  (FILLER FIELD)
F4                                DERIVED     *  EOF      CHARACTER           
    动态 LOBFILE。  文件名在字段 F4_FILE_NAME 中


表TESTLOAD_CLOB:
9 行加载成功
由于数据错误, 0 行没有加载。
由于所有 WHEN 子句失败, 0 行没有加载。
由于所有字段都为空的, 0 行没有加载。


为结合数组分配的空间:    66048字节(64行)
读取   缓冲区字节数: 1048576

跳过的逻辑记录总数:        0
读取的逻辑记录总数:        9
拒绝的逻辑记录总数:        0
废弃的逻辑记录总数:        0

从星期二 8月  07 21:40:31 2012开始运行
在星期二 8月  07 21:40:33 2012处运行结束

经过时间为: 00: 00: 01.97
CPU 时间为: 00: 00: 00.50(可?

4.查看sqlldr bad日志信息
(注:无)
5.查看数据库加载成功的数据
C:\sqlloader_exec\ppt_case13>sqlplus "scott/tiger"

SQL*Plus: Release 9.0.1.0.1 - Production on 星期二 8月 7 21:42:15 2012

(c) Copyright 2001 Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production

SQL> set lines 120
SQL> col f4 for a40
SQL> select * from testload_clob;

        F1 F2                             F3         F4
---------- ------------------------------ ---------- ----------------------------------------
         1 one row                        01-1月 -01 this is a test col in clob column
         2 two row                        01-1月 -02 this is a test col in clob column
         3 three row                      01-1月 -03 this is a test col in clob column
         4 four row                       01-1月 -04 this is a test col in clob column
         5 five row                       01-1月 -05 this is a test col in clob column
         6 six row                        01-1月 -06 this is a test col in clob column
         7 serven row                     01-1月 -07 this is a test col in clob column
         8 eight row                      01-1月 -08 this is a test col in clob column
         9 nine row                       01-1月 -09 this is a test col in clob column

已选择9行。

SQL>

五 个人总结


六 资料参考引用

http://afy.itpub.net/post/1128/22073

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11780477/viewspace-740310/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-12

  • 博文量
    203
  • 访问量
    662409