生活的乐趣都在过程里面,而目的只是在长长的过程之后一秒钟的高潮

Oracle sql loader简单使用

上一篇 / 下一篇  2008-01-10 21:39:20 / 个人分类:系统测试

    测试数据的构造对于软件测试工程师是最基本的技能.
  系统测试数据来源主要由以下构成:
  -产品
  -手工构造
  -生成
  -捕获
    -随机

SQL*LOADERORACLE的数据加载工具,通常用来将操作系统文件迁移到ORACLE数据库中。SQL*LOADER是大型数据  
 
仓库选择使用的加载方法,因为它提供了最快速的途径(DIRECTPARALLEL)。现在,我们抛开其理论不谈,用实例来使您快速掌握SQL*LOADER的使用方法。

我们知道,SQL*LOADER只能导入纯文本,所以我们现在开始以实例来讲解其用法。  
 
    一、已存在数据源result.csv,欲倒入ORACLESYSTEM用户下。  
 
       result.csv内容:  
 
     1,默认   Web  站点,192.168.2.254:80:,RUNNING  
 
     2,other,192.168.2.254:80:test.com,STOPPED  
 
     3,third,192.168.2.254:81:thirdabc.com,RUNNING  
 
    从中,我们看出4列,分别以逗号分隔,为变长字符串。  
 
    二、制定控制文件result.ctl  
  result.ctl
内容:  
 load   data  
  infile   'result.csv'  
  into   table   resultxt    
  (resultid   char   terminated   by   ',',  
  website   char   terminated   by   ',',  
  ipport   char   terminated   by   ',',  
  status   char   terminated   by   whitespace)  
 
    说明:  
 
     infile 指数据源文件 这里我们省略了默认的 discardfile   result.dsc   badfile   result.bad  
 
     into   table   resultxt  默认是INSERT,也可以into   table   resultxt   APPEND为追加方式,或REPLACE  
 
     terminated   by   ',' 指用逗号分隔  
 
     terminated   by   whitespace 结尾以空白分隔  
 
    三、此时我们执行加载:  
 D:\>sqlldr   userid=system/111111 control=result.ctl   log=resulthis.out  
  SQL*Loader:   Release   8.1.6.0.0   -   Production   on  
星期二   1   8   10:25:42   2002  
  (c)   Copyright   1999   Oracle   Corporation.   All   rights   reserved.  
  SQL*Loader-941:  
在描述表RESULTXT时出现错误  
  ORA-04043:  
对象   RESULTXT  不存在  
 
    提示出错,因为数据库没有对应的表。  
 
    四、在数据库建立表  
 
    create   table   resultxt  
  (resultid   varchar2(500),  
  website   varchar2(500),  
  ipport   varchar2(500),  
  status   varchar2(500))  
  /  
     五、重新执行加载  
 
    D:\>sqlldr   userid=system/111111   control=result.ctl   log=resulthis.out  
  SQL*Loader:   Release   8.1.6.0.0   -   Production   on  
星期二   1   8   10:31:57   2002  
  (c)   Copyright   1999   Oracle   Corporation.   All   rights   reserved.  
 
达到提交点,逻辑记录计数2  
 
达到提交点,逻辑记录计数3  
 
    已经成功!我们可以通过日志文件来分析其过程:resulthis.out内容如下:  
  SQL*Loader:   Release   8.1.6.0.0   -   Production   on  
星期二   1   8   10:31:57   2002  
  (c)   Copyright   1999   Oracle   Corporation.   All   rights   reserved.  
 
控制文件:   result.ctl  
 
数据文件:   result.csv  
 
错误文件:   result.bad  
 
废弃文件:  未作指定  

TAG: 系统测试

 

评分:0

我来说两句

Open Toolbar