标题: sqlldr加载数据到不同表的问题
lonjew
元帅
Rank: 1



UID 73191
精华 1
积分 30615
帖子 14941
威望 3
金币 14931
热心 12
阅读权限 100
注册 2008-1-28
状态 离线
sqlldr加载数据到不同表的问题

sqlldr加载数据到不同表的问题  ◆首先我们来创建测试表:  




D:\Orion>sqlplus eygle/eygle

SQL*Plus: Release 9.2.0.6.0 - Production on 星期一 11月 11 12::20 2007

Copyright (c) 1982, 2002,
Oracle
Corporation.  All rights reserved.

连接到:

Oracle
9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production

19:53:59 SQL> create table test1 (
19:54:14  2  a1 varchar2(10),
19:54:21  3  a2 varchar2(10),
19:54:26  4  a3 varchar2(10));

表已创建。

已用时间:  00: 00: 00.03
19:54:32 SQL> create table test2 (
19:54:35  2  a1 varchar2(10),
19:54:39  3  a2 varchar2(10),
19:54:40  4  a3 varchar2(10));

表已创建。

已用时间:  00: 00: 00.04
23:21:42 SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production中断开  
  ◆然后我们来测试数据:  




D:\Orion>cat data.txt
01,KunMing,YunNan
02,BeiJing,BeiJing
02,ShenZhe,ShenZhe
02,TianJin,TianJin
D:\Orion>  
  ◆控制文件  




D:\Orion>cat data.ctl
LOAD DATA
INFILE 'data.txt'
APPEND INTO TABLE test1
WHEN (2) = '1'
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY " " TRAILING NULLCOLS
( a1 POSITION(01:02), a2 POSITION(04:10), a3 POSITION(12:19) )
INTO TABLE test2
WHEN (2) = '2'
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY " " TRAILING NULLCOLS
( a1 POSITION(01:02), a2 POSITION(04:10), a3 POSITION(12:19) )  
  ◆加载数据  




D:\Orion>sqlldr eygle/eygle errors=20000 log=data.log control=data.ctl

SQL*Loader: Release 9.2.0.6.0 - Production on 星期一 11月 11 12:23:21 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

达到提交点,逻辑记录计数3
达到提交点,逻辑记录计数4  
  ◆检查结果  




D:\Orion>sqlplus eygle/eygle

SQL*Plus: Release 9.2.0.6.0 - Production on 星期一 11月11  12:31:29 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

连接到:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production

19:57:38 SQL> select * from test1;

A1        A2        A3
---------- ---------- ----------
01        KunMing    YunNan

已用时间:  00: 00: 00.00
19:57:42 SQL> select * from test2;

A1        A2        A3
---------- ---------- ----------
02        BeiJing    BeiJing
02        ShenZhe    ShenZhe
02        TianJin    TianJin

已用时间:  00: 00: 00.00
19:57:45 SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production中断开  
  注释:假如你不选择分区表,就可以用这个方式来直接加载数据到不同的数据表中。

网友 lonjew 签名 - 网友社区 ==
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-8-22 08:33
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP