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 ...
随机推荐
- Android学习地址
Google Android官方培训课程中文版http://hukai.me/android-training-course-in-chinese/
- PCA降维
http://blog.csdn.net/a784763307/article/details/17289317 这篇比较棒 openCV版 void PrintMatrix(CvMat *Matri ...
- NTP时间同步
1.设置NTP相关服务开机自启: # chkconfig ntpd on # chkconfig ntpdate on # chkconfig |grep ntp 2.启动NTP服务: # servi ...
- SCRUM报告(1)
我们组的PM是白杰,团队SCRUM 报告如下: 一.第一次spring会议内容: 1.确定所做项目的方向: 2.将调查问卷的结果进行统计,做了需求分析,大致了解了用户的想法: 3.确定了团队计划bac ...
- botbrew下写glib2程序
作者 He YiJun – storysnail<at>gmail.com 团队 ls 版权 转载请保留本声明! 本文档包含的原创代码根据General Public License,v3 ...
- JAVA缓存技术
介绍 JNotify:http://jnotify.sourceforge.net/,通过JNI技术,让Java代码可以实时的监控制定文件夹内文件的变动信息,支持Linux/Windows/MacOS ...
- 新版markdown功能发布!支持github flavored markdown!
让大家久等了!新版markdown功能一直拖到今天才发布,很是愧疚...但不管怎么样,总算发布了! 今年1月份发布第一版markdown功能之后,很多园友反馈说做得很烂,我们综合大家的反馈之后发现不仅 ...
- OpenSSL密码算法库: MD5示例小程序
OpenSSL http://www.openssl.org/ OpenSSL整个软件包大概可以分成三个主要的功能部分:密码算法库.SSL协议库以及应用程序.OpenSSL 的密码算法库包含多种加密算 ...
- SQLSERVER取当前月第一天和最后一天
--本月第一天: select dateadd(dd,-day(getdate())+1,getdate()) --本月最后一天: SELECT dateadd(ms,-3,DATEADD(mm, ...
- [每天默写一个算法]KMP
[每天默写一个算法]KMP 作业要求:默写String的KMP算法. KMP是经典的字符串匹配算法.复杂度为O(n+m) public static class StringKMP { /// < ...