Oracle   SQL   Loader的详细语法   
  SQL*LOADER是ORACLE的数据加载工具,通常用来将操作系统文件迁移到ORACLE数据库中。SQL*LOADER是大型数据   
  仓库选择使用的加载方法,因为它提供了最快速的途径(DIRECT,PARALLEL)。现在,我们抛开其理论不谈,用实例来使您快速掌握SQL*LOADER的使用方法。   
   首先,我们认识一下SQL*LOADER。   
   在NT下,SQL*LOADER的命令为SQLLDR,在UNIX下一般为sqlldr/sqlload。   
   如执行:d:\oracle>sqlldr   
  SQL*Loader:   Release   8.1.6.0.0   -   Production   on   星期二   1月   8   11:06:42   2002   
  (c)   Copyright   1999   Oracle   Corporation.   All   rights   reserved.   
  用法:   SQLLOAD   关键字   =   值   [,keyword=value,...]   
  有效的关键字:   
  userid   --   ORACLE   username/password   
  control   --   Control   file   name   
  log   --   Log   file   name   
  bad   --   Bad   file   name   
  data   --   Data   file   name   
  discard   --   Discard   file   name   
  discardmax   --   Number   of   discards   to   allow   (全部默认)   
  skip   --   Number   of   logical   records   to   skip   (默认0)   
  load   --   Number   of   logical   records   to   load   (全部默认)   
  errors   --   Number   of   errors   to   allow   (默认50)   
  rows   --   Number   of   rows   in   conventional   path   bind   array   or   between   direct   path   data   saves   
  (默认:   常规路径   64,   所有直接路径)   
  bindsize   --   Size   of   conventional   path   bind   array   in   bytes(默认65536)   
  silent   --   Suppress   messages   during   run   (header,feedback,errors,discards,partitions)   
  direct   --   use   direct   path   (默认FALSE)   
  parfile   --   parameter   file:   name   of   file   that   contains   parameter   specifications   
  parallel   --   do   parallel   load   (默认FALSE)   
  file   --   File   to   allocate   extents   from   
  skip_unusable_indexes   --   disallow/allow   unusable   indexes   or   index   partitions(默认FALSE)   
  skip_index_maintenance   --   do   not   maintain   indexes,   mark   affected   indexes   as   unusable(默认FALSE)   
  commit_discontinued   --   commit   loaded   rows   when   load   is   discontinued(默认FALSE)   
  readsize   --   Size   of   Read   buffer   (默认1048576)   
  PLEASE   NOTE:   命令行参数可以由位置或关键字指定   
  。前者的例子是   'sqlload  scott/tiger   foo';后者的例子是   'sqlload   control=foo userid=scott/tiger'.位置指定参数的时间必须早于但不可迟于由关键字指定的参数。例如,   
  'SQLLOAD   SCott/tiger   control=foo   logfile=log',   但'不允许                             
sqlload   scott/tiger   control=foo   log',即使允许 参数   'log'   的位置正确。   
  d:\oracle>   
  我们可以从中看到一些基本的帮助信息,这里,我用到的是中文的WIN2000 ADV SERVER。   
       我们知道,SQL*LOADER只能导入纯文本,所以我们现在开始以实例来讲解其用法。   
       一、已存在数据源result.csv,欲倒入ORACLE中FANCY用户下。   
         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=fancy/testpass   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=fancy/k1i7l6l8   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   
  废弃文件:   未作指定   
  :     
  (可废弃所有记录)   
  装载数:   ALL   
  跳过数:   0   
  允许的错误:   50   
  绑定数组:   64   行,最大   65536   字节   
  继续:   未作指定   
  所用路径:   常规   
  表RESULTXT   
  已载入从每个逻辑记录   
  插入选项对此表INSERT生效   
  列名   位置   长度   中止   包装数据类型   
  ------------------------------   ----------   -----   ----   ----   ---------------------   
  RESULTID   FIRST   *   ,   CHARACTER     
  WEBSITE   NEXT   *   ,   CHARACTER     
  IPPORT   NEXT   *   ,   CHARACTER     
  STATUS   NEXT   *   WHT   CHARACTER     
  表RESULTXT:     
  3   行载入成功   
  由于数据错误,   0   行没有载入。   
  由于所有   WHEN   子句失败,   0   行没有载入。   
  由于所有字段都为空的,   0   行没有载入。   
  为结合数组分配的空间:   65016字节(63行)   
  除绑定数组外的内存空间分配:   0字节   
  跳过的逻辑记录总数:   0   
  读取的逻辑记录总数:   3   
  拒绝的逻辑记录总数:   0   
  废弃的逻辑记录总数:   0   
  从星期二   1月   08   10:31:57   2002开始运行   
  在星期二   1月   08   10:32:00   2002处运行结束   
  经过时间为:   00:   00:   02.70   
  CPU   时间为:   00:   00:   00.10(可   
       六、并发操作   
  sqlldr   userid=/   control=result1.ctl   direct=true   parallel=true   
  sqlldr   userid=/   control=result2.ctl   direct=true   parallel=true   
  sqlldr   userid=/   control=result2.ctl   direct=true   parallel=true   
  当加载大量数据时(大约超过10GB),最好抑制日志的产生:   
       SQL>ALTER   TABLE   RESULTXT   nologging;   
  这样不产生REDO LOG,可以提高效率。然后在CONTROL文件中load   data上面加一行:unrecoverable     此选项必须要与DIRECT共同应用。   
   在并发操作时,ORACLE声称可以达到每小时处理100GB数据的能力!其实,估计能到1-10G就算不错了,开始可用结构 相同的文件,但只有少量数据,成功后开始加载大量数据,这样可以避免时间的浪费。   
  有关SQLLDR的问题     
  控制文件:input.ctl,内容如下:     
       load   data             --1、控制文件标识     
       infile   'test.txt'         --2、要输入的数据文件名为test.txt     
       append   into   table   test    --3、向表test中追加记录     
       fields   terminated   by   X'09'  --4、字段终止于X'09',是一个制表符(TAB)     
       (id,username,password,sj)     -----定义列对应顺序     
    
  其中append为数据装载方式,还有其他选项:     
  a、insert,为缺省方式,在数据装载开始时要求表为空     
  b、append,在表中追加新记录     
  c、replace,删除旧记录,替换成新装载的记录     
  d、truncate,同上      
==================================================================================
PS:    下面是我用C#写的调用SQL_LOADER的方法
Private Function Exec_SqlLoader(ByVal s_aFilePath As String, ByVal o_afileName As Hashtable, ByRef s_aErrMsg As String) As Boolean
        FilePath = s_aFilePath.Trim("\")
        Dim ctlPath As String = FilePath + "\control"
        s_aErrMsg = ""
        Try
            For i As Integer = 1 To 4
                Dim strmReader As New StreamReader(ctlPath + "\001" + i.ToString() + ".ctl")
                Dim ctlContent As String = strmReader.ReadToEnd()
                ctlContent = ctlContent.Replace("{{dataFile}}", o_afileName.Item(i.ToString))
                strmReader.Close()
                strmReader = Nothing
                Dim strCtlName As String = ctlPath + "\001" + i.ToString() + "new.ctl"
                Dim strLogName As String = ctlPath + "\001" + i.ToString() + "new.log"
                Dim strBadName As String = ctlPath + "\001" + i.ToString() + "new.bad"
                Dim strDscName As String = ctlPath + "\001" + i.ToString() + "new.dsc"
                Dim strmWriter As StreamWriter = File.CreateText(strCtlName)
                strmWriter.Write(ctlContent)
                strmWriter.Close()
                strmWriter = Nothing
                If (File.Exists(strBadName)) Then
                    File.Delete(strBadName)
                End If
                Dim connSetting As String() = thisVersion.MSD_ConnectionStr.Split(";")
                Dim serviceName As String = CType(connSetting.GetValue(0), String)
                serviceName = serviceName.Substring(serviceName.IndexOf("=") + 1)
                Dim userId As String = CType(connSetting.GetValue(1), String)
                userId = userId.Substring(userId.IndexOf("=") + 1)
                Dim password As String = CType(connSetting.GetValue(2), String)
                password = password.Substring(password.IndexOf("=") + 1)
                Dim strPathName As String
                strPathName = "sqlldr " + userId + "/" + password + "@" + serviceName + " control='" + strCtlName + "' log='" + strLogName + "' bad='" + strBadName + "' discard='" + strDscName + "' errors=500"
                Microsoft.VisualBasic.Shell(strPathName, AppWinStyle.MinimizedFocus, True)
                If (File.Exists(strBadName)) Then
                    File.Copy(strBadName, FilePath + "\BatchLog\ERROR_001" + i.ToString() + ".txt", True)
                    a_sErrMsg += "这里写抛出的警告信息" + vbCrLf + vbTab
                    
                End If
            Next
            
            Return True
        Catch ex As Exception
            a_sErrMsg += ex.ToString()
            ms_BatchLogMsg = ex.Message 
            Return False
        End Try
    End Function

ORACLE SQLloader详细语法的更多相关文章

  1. Oracle存储过程基本语法介绍

    Oracle存储过程基本语法 存储过程 1 CREATE OR REPLACE PROCEDURE 存储过程名 2 IS 3 BEGIN 4 NULL; 5 END; 行1: CREATE OR RE ...

  2. Oracle存储过程基本语法 存储过程

    Oracle存储过程基本语法 存储过程 1 CREATE OR REPLACE PROCEDURE 存储过程名 2 IS 3 BEGIN 4 NULL; 5 END; 行1: CREATE OR RE ...

  3. Oracle Hints详细解释

    特别介绍给大家Oracle Hints之前,让我们知道下Oracle Hints什么,然后好Oracle Hints,我们希望实际.基于成本的优化器是很聪明,在大多数情况下,将选择正确的优化,减少DB ...

  4. Oracle Update 语句语法与性能分析 - 多表关联

    Oracle Update 语句语法与性能分析 - 多表关联   为了方便起见,建立了以下简单模型,和构造了部分测试数据: 在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create ...

  5. 伪静态规则写法RewriteRule-htaccess详细语法使用

    一.正则表达式教程伪静态规则写法RewriteRule-htaccess详细语法使用教程分享简单说下:伪静态实际上是利用PHP把当前地址解析成另外一种方法进行访问网站!要学伪静态规则的写法,你必须得懂 ...

  6. PL/SQL Developer 连接Oracle数据库详细配置方法

    PL/SQL Developer 连接Oracle数据库详细配置方法 近段时间很多网友提出监听配置相关问题,客户终端(Client)无法连接服务器端(Server).本文现对监听配置作一简单介绍,给出 ...

  7. Deepin系统手动安装oracle jdk8详细教程

    Deepin系统手动安装oracle jdk8详细教程 oracle官网下载jdk压缩包,使用 sudo tar -zxf jdk***解压文件,我放在在了home/diy/java/jdk路径下. ...

  8. Oracle的基本语法,存储函数及触发器

    1.PL/SQL    PL/SQL是Oracle对 ql语言的过程化扩展,指在 SQL 命令语言中增加了过程处理语句,使SQL语言具有过程处理能力.把 SQL 语言的数据操纵能  力与过程语言的数据 ...

  9. oracle plsql基本语法

    oracle plsql 基本语法 --plsql默认规则:plsql赋值用":=" plsql判断用"=" plsql输入用"&" ...

随机推荐

  1. Beaglebone Back学习五(PWM测试)

    PWM测试 参考链接 1 Enable PWM on BeagleBone with Device Tree overlays 2Using PWM on the Beaglebone Black 3 ...

  2. Windows Service 访问远程共享权限设置

    最近为实现共享目录之间的文件同步,开发了一个Windows Service. 考虑到在拷贝过程中,如果网络忽然抽风访问不了,导致文件拷贝不完整的情况,果断抛弃.Net 自带的 COPY 方法,而使用D ...

  3. AJAX 原理(转摘)

    在写这篇文章之前,曾经写过一篇关于AJAX技术的随笔,不过涉及到的方面很窄,对AJAX技术的背景.原理.优缺点等各个方面都很少涉及null.这次写这篇文章的背景是因为公司需要对内部程序员做一个培训.项 ...

  4. android 注销

    1.在个人中心退出系统MainActivity 2.清空保存的登录数据 3.打开登录LoginActivity 方法: SharedPreferencesManager.getInstance(mCo ...

  5. BZOJ 4123 [Baltic2015] Hacker 解题报告

    首先,Alice 会选择一个长度为 $\lfloor\frac{n+1}{2}\rfloor$ 的区间,我们把这个长度记为 $len$. 有这么一个结论:令 $F_i$ 为覆盖 $i$ 点的所有长度为 ...

  6. Matlab划分测试集和训练集

    % x是原数据集,分出训练样本和测试样本 [ndata, D] = size(X); %ndata样本数,D维数 R = randperm(ndata); %1到n这些数随机打乱得到的一个随机数字序列 ...

  7. Why are very few schools involved in deep learning research? Why are they still hooked on to Bayesian methods?

    Why are very few schools involved in deep learning research? Why are they still hooked on to Bayesia ...

  8. spoj 416

    又臭又长的烂代码 ...... #include <iostream> #include <cstdio> #include <cstring> #include ...

  9. Java 程序检查远程服务器状态

    通常我们以命令的方式判断远程服务器是否正常运行有两种方式,ping 或 telnet 一个远程端口.假设我们要检查的远程服务器都是 Linux 系统. 从 JDK 1.5 以后, InetAddres ...

  10. mpi冒泡排序并行化

    一.实验目的与实验要求 1.实验目的 (1)学会将串行程序改为并行程序. (2)学会mpich2的使用. (3)学会openmp的配置. (4)mpi与openmp之间的比较. 2.实验要求 (1)将 ...