SQL*Loader之CASE6
CASE6
1. SQL脚本
[oracle@node3 ulcase]$ cat ulcase6.sql
set termout off
rem host write sys$output "Building case 6 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)); create unique index empix on emp(empno); exit
2. 控制文件
[oracle@node3 ulcase]$ cat ulcase6.ctl
-- Copyright (c) 1991, 2004 Oracle. All rights reserved.
-- NAME
-- ulcase6.ctl - SQL*Loader Case Study 6: Loading Data Using the
-- Direct Path Load Method
--
-- DESCRIPTION
-- This case study demonstrates the following:
-- Use of the direct path load method to load and index data.
--
-- How to specify the indexes for which the data is presorted.
--
-- Use of the NULLIF clause.
--
-- Loading all-blank numeric fields as NULL.
--
-- TO RUN THIS CASE STUDY:
-- 1. Before executing this control file, log in to SQL*Plus as
-- scott/tiger. Enter @ulcase6 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=ulcase6.ctl LOG=ulcase6.log DIRECT=TRUE
--
-- NOTES ABOUT THIS CONTROL FILE
-- The SORTED INDEXES statement identifies the indexes on which
-- the data is sorted. This statement indicates that the datafile
-- is sorted on the columns in the empix index. It allows
-- SQL*Loader to optimize index creation by eliminating the sort
-- phase for this data when using the direct path load method.
--
-- The NULLIF...BLANKS clause specifies that the column should
-- be loaded as NULL if the field in the datafile consists of
-- all blanks.
--
LOAD DATA
INFILE 'ulcase6.dat'
REPLACE
INTO TABLE emp
SORTED INDEXES (empix)
(empno POSITION(1:4),
ename POSITION(6:15),
job POSITION(17:25),
mgr POSITION(27:30) NULLIF mgr=blanks,
sal POSITION(32:39) NULLIF sal=blanks,
comm POSITION(41:48) NULLIF comm=blanks,
deptno POSITION(50:51) NULLIF empno=blanks)
3. 数据文件
[oracle@node3 ulcase]$ cat ulcase6.dat
7499 ALLEN SALESMAN 7698 1600.00 300.00 30
7566 JONES MANAGER 7839 3123.75 20
7654 MARTIN SALESMAN 7698 1312.50 1400.00 30
7658 CHAN ANALYST 7566 3450.00 20
7782 CLARK MANAGER 7839 2572.50 10
7839 KING PRESIDENT 5500.00 10
7934 MILLER CLERK 7782 920.00 10
执行后结果:
[oracle@node3 ulcase]$ sqlplus scott/tiger @ulcase6.sql
[oracle@node3 ulcase]$ sqlldr userid=scott/tiger control=ulcase6.ctl direct=yes
--注意,上述命令多了一个参数direct=yes,代表直接路径插入
SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
----- ---------- --------- ----- --------- ------- ----- ------
7499 ALLEN SALESMAN 7698 1600 300 30
7566 JONES MANAGER 7839 3124 20
7654 MARTIN SALESMAN 7698 1313 1400 30
7658 CHAN ANALYST 7566 3450 20
7782 CLARK MANAGER 7839 2573 10
7839 KING PRESIDENT 5500 10
7934 MILLER CLERK 7782 920 10 7 rows selected.
查看日志文件:
[oracle@node3 ulcase]$ vim ulcase6.log
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Sep 19 02:49:21 2014 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Control File: ulcase6.ctl
Data File: ulcase6.dat
Bad File: ulcase6.bad
Discard File: none specified (Allow all discards) Number to load: ALL
Number to skip: 0
Errors allowed: 50
Continuation: none specified
Path used: Direct Table EMP, loaded from every logical record.
Insert option in effect for this table: REPLACE Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
EMPNO 1:4 4 CHARACTER
ENAME 6:15 10 CHARACTER
JOB 17:25 9 CHARACTER
MGR 27:30 4 CHARACTER
NULL if MGR = BLANKS
SAL 32:39 8 CHARACTER
NULL if SAL = BLANKS
COMM 41:48 8 CHARACTER
NULL if COMM = BLANKS
DEPTNO 50:51 2 CHARACTER
NULL if EMPNO = BLANKS The following index(es) on table EMP were processed:
index SCOTT.EMPIX loaded successfully with 7 keys 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. Bind array size not used in direct path.
Column array rows : 5000
Stream buffer bytes: 256000
Read buffer bytes: 1048576 Total logical records skipped: 0
Total logical records read: 7
Total logical records rejected: 0
Total logical records discarded: 0
Total stream buffers loaded by SQL*Loader main thread: 1
Total stream buffers loaded by SQL*Loader load thread: 0 Run began on Fri Sep 19 02:49:21 2014
Run ended on Fri Sep 19 02:49:27 2014 Elapsed time was: 00:00:06.66
CPU time was: 00:00:01.27
注意:在本例中
1> SORTED INDEXES (empix)指明数据文件的数据是按照索引empix对应的列排过序的,只有在直接路径插入下有效,即sqlldr命令中需指明direct=yes,这样可极大提高插入效率。
2> NULLIF...BLANKS子句指明列对应数据文件的位置如果是空格的话,当null处理。
SQL*Loader之CASE6的更多相关文章
- SQL*LOADER错误总结
在使用SQL*LOADER装载数据时,由于平面文件的多样化和数据格式问题总会遇到形形色色的一些小问题,下面是工作中累积.整理记录的遇到的一些形形色色错误.希望能对大家有些用处.(今天突然看到自己以前整 ...
- Bulkcopy对应的实现是Oracle的SQL*LOADER,期间造成Index Unusable,并且last_ddl_time上是不体现的
部分项目反馈系统整体突然变慢,经查询发现一个系统核心的大数据表的索引状态全部是Unusable. 导致索引失效的直接原因:当某些操作导致数据的rowid改变,索引就会完全失效. 那什么时候会导致row ...
- SQL*Loader之CASE11
CASE11 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase11.sql set termout off rem host write sys$output &q ...
- SQL*Loader之CASE10
CASE10 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase10.sql rem host write sys$output "Building dem ...
- SQL*Loader之CASE9
CASE9 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase9.sql set termout off rem host write sys$output &quo ...
- SQL*Loader之CASE8
CASE8 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase8.sql set termout off rem host write sys$output &quo ...
- SQL*Loader之CASE7
CASE7 1. SQL脚本 case7包含两个SQL脚本,一个是删除脚本ulcase7e.sql,一个是创建脚本ulcase7s.sql [oracle@node3 ulcase]$ cat ulc ...
- SQL*Loader之CASE5
CASE5 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase5.sql set termout off rem host write sys$output &quo ...
- SQL*Loader之CASE4
CASE4 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase4.sql set termout off rem host write sys$output &quo ...
随机推荐
- shell学习
set -x 进入调试模式,会把每一个命令实际执行的命令打印出来,也就是会把一些参数扩展后的样子打印出来. set +x 退出调试模式自定义变量:x=7,y=8echo `expr $x + $y` ...
- Windows 安装 openssl
http://slproweb.com/products/Win32OpenSSL.html File Type Description Win32 OpenSSL v1.1.0b Light 3MB ...
- 如果你觉得我的博客对你有帮助,请帮忙加点我所在团队博客访问量http://home.cnblogs.com/u/newbe/
RT http://home.cnblogs.com/u/newbe/ 跪谢~
- Android中自定义checkbox样式
1.首先在drawable文件夹中添加drawable文件checkbox_style.xml.
- Tomcat相关的笔记
本文只是记录一下tomcat运维用到过的知识,都是网络上收集来的资料,侵删 JVM的内存 内存分配 -XX:PermSize尽量比-XX:MaxPermSize小,-XX:MaxPermSize> ...
- C# 的析构
首先介绍下关于C#的GC垃圾回收器,有了这个垃圾回收器c#的开发人员可以不用像C++开发人员那样关心垃圾回收! 但是GC是把双刃剑,GC仅仅对于托管资源进行管理,对非托管资源却无能为力,并且C#的开发 ...
- 。net初学
这一周主要是对.net语法基础知识的简介以及一些作业练习,大部分还是与c语言有关联.一开始语法上有差异,写起代码来有困难,逻辑有点转换不过来.但是通过上周的练习,现在写起 作业来,还是挺快的. ...
- alert的换行问题
一种比较复杂的方法,但这种方法使用起来对所有型号的浏览器都能任意分辨: //浏览器类型判定 function getOs() { if(navigator.userAgent.indexOf(&quo ...
- STC12C5A60S2笔记7(定时器)
1. 基本特性 STC12C5A60S2单片机集成了两个16位定时/计数器. 1)寄存器 1.1)TMOD 定时器工作方式控制寄存器,包括13位寄存器.16位寄存器.8位寄存器等: 1.2)TCON ...
- 冲刺阶段 day13
---恢复内容开始--- 项目进展 今天星期三,我们将专业管理部分又继续做了完善,之前漏掉的几项功也一一补全,没能实现的数据库部分也已经进行了完善,并且对已经完成的部分进行了检测,数据库的部分还有待进 ...