当前所在位置:珠峰网资讯 >> 计算机 >> Oracle认证 >> 正文
OracleSQLLoader的详细语法一
发布时间:2010/9/21 9:51:17 来源:深圳教育在线 编辑:well

  -

  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 结尾以空白分隔

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved