SQLLOADER 9 载入每行的行号

一 描述

此档是sqlloader学习的第9篇.在载入数据之时将数据行号一并载入数据库.(源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_case9

三 过程设计

1.准备的flat源数据
fsdfasj
fasdjfasdfl
asdf
dsaf
we
dsaf
(仅一列)

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

set termout off

drop table tab_p9;
create table tab_p9 (seqno number(2),text varchar2(1024));
exit;

3.相关文件ppt_case9.ctl
load data
infile *
into table tab_p9
replace
( seqno RECNUM,
text Position(1:1024))
BEGINDATA
fsdfasj
fasdjfasdfl
asdf
dsaf
we
dsaf

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

四 详细步骤操作

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

SQL*Plus: Release 9.0.1.0.1 - Production on 星期一 8月 6 21:19:09 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> @ppt_case9
从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_case9>

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

SQL*Loader: Release 9.0.1.1.1 - Production on 星期一 8月 6 21:19:50 2012

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

达到提交点,逻辑记录计数5
达到提交点,逻辑记录计数6

C:\sqlloader_exec\ppt_case9>

3.查看sqlldr日志信息

SQL*Loader: Release 9.0.1.1.1 - Production on 星期一 8月 6 21:19:50 2012

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

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

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

表TAB_P9
已加载从每个逻辑记录
插入选项对此表REPLACE生效

   列名                        位置      长度  中止 包装数据类型
------------------------------ ---------- ----- ---- ---- ---------------------
SEQNO                                                     RECNUM
TEXT                              1:1024  1024           CHARACTER           


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


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

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

从星期一 8月  06 21:19:50 2012开始运行
在星期一 8月  06 21:19:51 2012处运行结束

经过时间为: 00: 00: 00.91
CPU 时间为: 00: 00: 00.02(可?

4.查看数据库加载成功的数据
C:\sqlloader_exec\ppt_case9>sqlplus "scott/tiger"

SQL*Plus: Release 9.0.1.0.1 - Production on 星期一 8月 6 21:21:49 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 100
SQL> col text for a30
SQL> select * from tab_p9;

     SEQNO TEXT
---------- ------------------------------
         1 fsdfasj
         2 fasdjfasdfl
         3 asdf
         4 dsaf
         5 we
         6 dsaf

已选择6行。

SQL>

五 个人总结

使用RECNUM参数向列中添加并未存在的行号.

六 资料参考引用

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

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

转载于:http://blog.itpub.net/11780477/viewspace-740143/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值