SQL*Loader之CASE2
CASE2
1. 控制文件
[oracle@node3 ulcase]$ cat ulcase2.ctl
-- NAME
-- ulcase2.ctl - SQL*Loader Case Study 2: Loading Fixed-Format Files
--
-- DESCRIPTION
-- This control file demonstrates the following:
-- Use of a separate data file.
--
-- Data conversions.
--
-- TO RUN THIS CASE STUDY:
-- 1. Before executing this control file, log in to SQL*Plus as
-- scott/tiger. Enter @ulcase1 to execute the SQL script for
-- this case study. This prepares and populates tables and
-- then returns you to the system prompt. It is the same script
-- used to prepare for case study 1, so if you have already
-- run case study 1, you can skip this step.
--
-- 2. At the system prompt, invoke the case study as follows:
-- sqlldr USERID=scott/tiger CONTROL=ulcase2.ctl LOG=ulcase2.log
--
-- NOTES ABOUT THIS CONTROL FILE
-- The LOAD DATA statement is required at the beginning of the
-- control file.
--
-- The name of the file containing data follows the INFILE parameter.
--
-- The INTO TABLE statement is required to identify the table to
-- be loaded into.
--
-- empno, ename, job, and so on are names of columns in table emp.
-- The datatypes (INTEGER EXTERNAL, CHAR, DECIMAL EXTERNAL) identify
-- the datatype of data fields in the file, not of corresponding
-- columns in the emp table.
--
-- Note that the set of column specifications is enclosed in
-- parentheses.
--
-- Records loaded in this example from the emp table contain
-- department numbers. Unless the dept table is loaded first,
-- referential integrity checking rejects these records (if
-- referential integrity constraints are enabled for the emp table). --
LOAD DATA
INFILE 'ulcase2.dat'
INTO TABLE EMP ( EMPNO POSITION(01:04) INTEGER EXTERNAL,
ENAME POSITION(06:15) CHAR,
JOB POSITION(17:25) CHAR,
MGR POSITION(27:30) INTEGER EXTERNAL,
SAL POSITION(32:39) DECIMAL EXTERNAL,
COMM POSITION(41:48) DECIMAL EXTERNAL,
DEPTNO POSITION(50:51) INTEGER EXTERNAL)
2. 数据文件
[oracle@node3 ulcase]$ cat ulcase2.dat
7782 CLARK MANAGER 7839 2572.50 10
7839 KING PRESIDENT 5500.00 10
7934 MILLER CLERK 7782 920.00 10
7566 JONES MANAGER 7839 3123.75 20
7499 ALLEN SALESMAN 7698 1600.00 300.00 30
7654 MARTIN SALESMAN 7698 1312.50 1400.00 30
7658 CHAN ANALYST 7566 3450.00 20
执行后结果:
SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
----- ---------- --------- ---------- --------- --------- ---------- ----------
7782 CLARK MANAGER 7839 2572.5 10
7839 KING PRESIDENT 5500 10
7934 MILLER CLERK 7782 920 10
7566 JONES MANAGER 7839 3123.75 20
7499 ALLEN SALESMAN 7698 1600 300 30
7654 MARTIN SALESMAN 7698 1312.5 1400 30
7658 CHAN ANALYST 7566 3450 20 7 rows selected.
总结:在本例中
1> INFILE 'ulcase2.dat'指定外部数据源
2> The datatypes (INTEGER EXTERNAL, CHAR, DECIMAL EXTERNAL) identify the datatype of data fields in the file, not of corresponding columns in the emp table.如果数据就在控制文件中,不用指定INTEGER EXTERNAL, CHAR, DECIMAL EXTERNAL等数据类型。
3> 在本例中,因为数据排列比较规则,所以可以在列中指定所需数据的具体位置POSITION(01:04)
SQL*Loader之CASE2的更多相关文章
- 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之CASE6
CASE6 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase6.sql set termout off rem host write sys$output &quo ...
- SQL*Loader之CASE5
CASE5 1. SQL脚本 [oracle@node3 ulcase]$ cat ulcase5.sql set termout off rem host write sys$output &quo ...
随机推荐
- Refresh recovery area usage data after manually deleting files under recovery area
Original source: http://www.dba-oracle.com/t_v$_flash_recovery_area.htm If you manually delete files ...
- XStream学习笔记
XStream 所需jar包: xstream-1.3.jar xpp3_min-1.1.4c.jar xmlpull-1.1.3.1.jar 目录: 1.注解去除,标签中带有包名的节点 2.注解修改 ...
- proxyd.c
/**************************************************************************** * program: proxyd * mo ...
- ImageView
ImageView支持的XML属性及相关方法 XML属性 相关方法 说明 android:adjustViewBounds setAdjustViewBounds(boolean) 是否调整自己的边界 ...
- 拾遗——java多线程
由于sleep()方法是Thread类的方法,因此它不能改变对象的机锁.所以当在一个Synchronized方法中调用sleep()时,线程虽然休眠了,但是对象的机锁没有被释放,其他线程仍然无法访问这 ...
- Android ExpandableListView
ExpandableListView 结合SimpleExpandableListAdapter用法 最终实现效果: activity_main.xml <?xml version=" ...
- 【转】MongoDB安全配置
[转自]http://drops.wooyun.org/%E8%BF%90%E7%BB%B4%E5%AE%89%E5%85%A8/2470 0x00 MongoDB权限介绍 1.MongoDB安装时不 ...
- 设计模式之美:Null Object(空对象)
索引 意图 结构 参与者 适用性 效果 相关模式 实现 实现方式(一):Null Object 的示例实现. 意图 通过对缺失对象的封装,以提供默认无任何行为的对象替代品. Encapsulate t ...
- 如何通过自定义注解实现AOP切点定义
面向切面编程(Aspect Oriented Programming, AOP)是面向对象编程(Object Oriented Programming,OOP)的强大补充,通过横切面注入的方式引入其他 ...
- Nim教程【十】
openarray类型 注意:openarray类型只能用于参数 固定大小的数组虽然性能不错,但过于呆板,使用取来不是很方便 对于一个方法来说,传入参数如果是一个数组,最好是不要限制数组的长度 也就是 ...