CASE9

1. SQL脚本

[oracle@node3 ulcase]$ cat ulcase9.sql

set termout off

rem host write sys$output "Building case 9 demonstration tables.  Please wait"

drop table emp;

create table emp
(empno number(4) not null,
ename char(10),
job char(9),
mgr number(4),
hiredate date,
sal number(7,2),
comm number(7,2),
deptno number(2),
resume clob); exit

2. 控制文件

[oracle@node3 ulcase]$ cat ulcase9.ctl

-- Copyright (c) 1991, 2004 Oracle.  All rights reserved.
-- NAME
-- ulcase9.ctl - SQL*Loader Case Study 9: Loading LOBFILEs (CLOBs)
--
-- DESCRIPTION
-- This case study demonstrates the following:
-- Adding a CLOB column called resume to table emp.
--
-- Using a filler field (res_file).
--
-- Loading multiple LOBFILEs into the emp table.
--
-- TO RUN THIS CASE STUDY:
-- 1. Before executing this control file, log in to SQL*Plus as
-- scott/tiger. Enter @ulcase9 to execute the SQL script for
-- this case study. This prepares and populates tables and
-- then returns you to the system prompt.
--
-- 2. At the system prompt, invoke the case study as follows:
-- sqlldr USERID=scott/tiger CONTROL=ulcase9.ctl LOG=ulcase9.log
--
-- NOTES ABOUT THIS CONTROL FILE
-- This is an example of using SQL Loader to load LOBs from
-- secondary data file.
--
-- There is one file per resume (the "TERMINATED BY EOF" clause
-- indicates this) and the name of the file containing the resume
-- is in field res_file.
--
-- res_file is a filler field. The filler field is assigned values
-- from the data field to which it is mapped. This means that the
-- file name stored in the field is not loaded into any field in
-- the table.
--
-- The resume column is loaded as a CLOB. The LOBFILE function specifies
-- the field name in which the name of the file that contains data for
-- LOB field is provided.
--
-- The field name for column RESUME is in quotation marks because
-- RESUME is also a keyword for SQL*Loader. The quotation marks force
-- SQL*Loader to treat it as a column name instead.
--
LOAD DATA
INFILE *
INTO TABLE EMP
REPLACE
FIELDS TERMINATED BY ','
( EMPNO INTEGER EXTERNAL,
ENAME CHAR,
JOB CHAR,
MGR INTEGER EXTERNAL,
SAL DECIMAL EXTERNAL,
COMM DECIMAL EXTERNAL,
DEPTNO INTEGER EXTERNAL,
RES_FILE FILLER CHAR,
"RESUME" LOBFILE (RES_FILE) TERMINATED BY EOF NULLIF RES_FILE = 'NONE'
) BEGINDATA
7782,CLARK,MANAGER,7839,2572.50,,10,ulcase91.dat
7839,KING,PRESIDENT,,5500.00,,10,ulcase92.dat
7934,MILLER,CLERK,7782,920.00,,10,ulcase93.dat
7566,JONES,MANAGER,7839,3123.75,,20,ulcase94.dat
7499,ALLEN,SALESMAN,7698,1600.00,300.00,30,ulcase95.dat
7654,MARTIN,SALESMAN,7698,1312.50,1400.00,30,ulcase96.dat
7658,CHAN,ANALYST,7566,3450.00,,20,NONE

3. 数据文件

在这个案例中,最后一列RESUME是CLOB类型,它的内容以ulcase91.dat等文件存在。在这里,我们只列出其中一个数据文件,其它类似。

[oracle@node3 ulcase]$ cat ulcase91.dat

                          Resume for Mary Clark

Career Objective: Manage a sales team with consistent record breaking
performance. Education: BA Business University of Iowa 1992 Experience: 1992-1994 - Sales Support at MicroSales Inc.
Won "Best Sales Support" award in 1993 and 1994 1994-Present - Sales Manager at MicroSales Inc.
Most sales in mid-South division for 2 years

执行后结果:

[oracle@node3 ulcase]$ sqlplus scott/tiger @ulcase9.sql

[oracle@node3 ulcase]$ sqlldr userid=scott/tiger control=ulcase9.ctl

SQL> set long 9999
SQL> select empno,resume from emp where rownum=1; EMPNO
-----
RESUME
--------------------------------------------------------------------------------
7782
Resume for Mary Clark Career Objective: Manage a sales team with consistent record breaking
performance. Education: BA Business University of Iowa 1992 Experience: 1992-1994 - Sales Support at MicroSales Inc. EMPNO
-----
RESUME
--------------------------------------------------------------------------------
Won "Best Sales Support" award in 1993 and 1994 1994-Present - Sales Manager at MicroSales Inc.
Most sales in mid-South division for 2 years

查看日志文件:

[oracle@node3 ulcase]$ cat ulcase9.log

SQL*Loader: Release 11.2.0.1.0 - Production on Fri Sep 19 03:48:24 2014

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

Control File:   ulcase9.ctl
Data File: ulcase9.ctl
Bad File: ulcase9.bad
Discard File: none specified (Allow all discards) Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional Table EMP, loaded from every logical record.
Insert option in effect for this table: REPLACE Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
EMPNO FIRST * , CHARACTER
ENAME NEXT * , CHARACTER
JOB NEXT * , CHARACTER
MGR NEXT * , CHARACTER
SAL NEXT * , CHARACTER
COMM NEXT * , CHARACTER
DEPTNO NEXT * , CHARACTER
RES_FILE NEXT * , CHARACTER
(FILLER FIELD)
"RESUME" DERIVED * EOF CHARACTER
Dynamic LOBFILE. Filename in field RES_FILE
NULL if RES_FILE = 0X4e4f4e45(character 'NONE') Table EMP:
7 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: 132096 bytes(64 rows)
Read buffer bytes: 1048576 Total logical records skipped: 0
Total logical records read: 7
Total logical records rejected: 0
Total logical records discarded: 0 Run began on Fri Sep 19 03:48:24 2014
Run ended on Fri Sep 19 03:48:25 2014 Elapsed time was: 00:00:00.45
CPU time was: 00:00:00.11

SQL*Loader之CASE9的更多相关文章

  1. SQL*LOADER错误总结

    在使用SQL*LOADER装载数据时,由于平面文件的多样化和数据格式问题总会遇到形形色色的一些小问题,下面是工作中累积.整理记录的遇到的一些形形色色错误.希望能对大家有些用处.(今天突然看到自己以前整 ...

  2. Bulkcopy对应的实现是Oracle的SQL*LOADER,期间造成Index Unusable,并且last_ddl_time上是不体现的

    部分项目反馈系统整体突然变慢,经查询发现一个系统核心的大数据表的索引状态全部是Unusable. 导致索引失效的直接原因:当某些操作导致数据的rowid改变,索引就会完全失效. 那什么时候会导致row ...

  3. SQL*Loader之CASE11

    CASE11 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase11.sql set termout off rem host write sys$output &q ...

  4. SQL*Loader之CASE10

    CASE10 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase10.sql rem host write sys$output "Building dem ...

  5. SQL*Loader之CASE8

    CASE8 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase8.sql set termout off rem host write sys$output &quo ...

  6. SQL*Loader之CASE7

    CASE7 1. SQL脚本 case7包含两个SQL脚本,一个是删除脚本ulcase7e.sql,一个是创建脚本ulcase7s.sql [oracle@node3 ulcase]$ cat ulc ...

  7. SQL*Loader之CASE6

    CASE6 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase6.sql set termout off rem host write sys$output &quo ...

  8. SQL*Loader之CASE5

    CASE5 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase5.sql set termout off rem host write sys$output &quo ...

  9. SQL*Loader之CASE4

    CASE4 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase4.sql set termout off rem host write sys$output &quo ...

随机推荐

  1. Activity调用静态方法改变UI,使用Handler来改变UI显示

    本人菜鸟,请各位多多指点,不足之处,请斧正.没啥技术含量,就权当丰富下mono for android的小代码. Activity调用静态方法改变UI using System; using Andr ...

  2. Mysql运行SQL文件 错误Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    问题描述 想从服务器上DOWN下数据库.操作:先把数据库转存为SQL文件,然后在本地利用navicate运行SQL文件,出现错误信息: Incorrect table definition;there ...

  3. Java-ios推送

    之前做的消息推送,向Android和ios客户端推送.这里只说ios的推送,ios的推送最后都会推送到苹果的APNS服务器上,再有APNS服务器推送到ios设备上.因为考虑到这一点,第一版的消息推送苹 ...

  4. 对初学者的MPLS 常见问题

    对初学者的MPLS 常见问题 2015年6月8日 16:04 阅读 186 问:什么是多协议标签交换 (MPLS)? 答:MPLS是一种数据包转发技术,该技术使用标签来做出数据转发决策. 利用MPLS ...

  5. dojo分析之declare接口

    欢迎转载opendevkit文章, 文章原始地址: http://www.opendevkit.com/?e=57 declare接口是dojo定义类系统的关键函数, 类系统就是抽象,封装,继承.do ...

  6. PHP程序员面临的成长瓶颈

    作为Web开发中应用最广泛的语言之一,PHP有着大量的粉丝,那么你是一名优秀的程序员吗?在进行自我修炼的同时,你是否想过面对各种各样的问题,我该如何突破自身的瓶颈,以便更好的发展呢? PHP工程师面临 ...

  7. 【WPF】如何把一个枚举属性绑定到多个RadioButton

    一.说明 很多时候,我们要把一个枚举的属性的绑定到一组RadioButton上.大家都知道是使用IValueConverter来做,但到底怎么做才好? 而且多个RadioButton的Checked和 ...

  8. MySql学习(MariaDb)

    资料 http://www.cnblogs.com/lyhabc/p/3691555.html http://www.cnblogs.com/lyhabc/p/3691555.html MariaDb ...

  9. 【腾讯Bugly干货分享】深入理解 ButterKnife,让你的程序学会写代码

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/578753c0c9da73584b025875 0.引子 话说我们做程序员的,都 ...

  10. 设计模式之美:Private Class Data(私有类数据)

    索引 意图 结构 参与者 适用性 效果 实现 实现方式(一):实现对初始化数据的封装. 意图 封装类的初始化数据,控制对类的属性的更改,并保持类数据与使用数据的方法间的隔离. Encapsulate ...