数据批量导入Oracle数据库

仓库选择使用的加载方法,因为它提供了最快速的途径(DIRECT,PARALLEL)。现在,我们抛开其理论不谈,用实例来使
您快速掌握SQL*LOADER的使用方法。
  首先,我们认识一下SQL*LOADER。
  在NT下,SQL*LOADER的命令为SQLLDR,在UNIX下一般为sqlldr/sqlload。
  如执行:dracle>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 p
ath data saves
(默认: 常规路径 64, 所有直接路径)
  bindsize -- Size of conventional path bind array in bytes(默认65536)
    silent -- Supdivss messages during run (header,feedback,errors,discards,part
itions)
    direct -- use direct path                    (默认FALSE)
   parfile -- parameter file: name of file that contains parameter specification
s
  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' 的位置正确。
dracle>
      我们可以从中看到一些基本的帮助信息,这里,我用到的是中文的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就算不错了,开始可用结构
    相同的文件,但只有少量数据,成功后开始加载大量数据,这样可以避免时间的浪费。

我的示例:
一、在数据库建立表格weather如下:
create table weather(
outlook varchar(20),
temperature float,
humidity float,
windy varchar(10),
play varchar(10)
)
二、在F盘建立两个文件 分别如下:
#1、result.ctl内容如下:
load data
infile 'result.csv'
into table weather
(outlook char terminated by ',',
temperature  char terminated by ',',
humidity char terminated by ',',
windy char terminated by ',',
play char terminated by ','
)
#2、result.csv内容如下:
sunny,85,85,FALSE,no
sunny,80,90,TRUE,no
overcast,83,86,FALSE,yes
rainy,70,96,FALSE,yes
rainy,68,80,FALSE,yes
rainy,65,70,TRUE,no
overcast,64,65,TRUE,yes
sunny,72,95,FALSE,no
sunny,69,70,FALSE,yes
rainy,75,80,FALSE,yes
sunny,75,70,TRUE,yes
overcast,72,90,TRUE,yes
overcast,81,75,FALSE,yes
rainy,71,91,TRUE,no
三、命令行下执行
F:>sqlldr userid=cqsb/ctbujx123  control=result.ctl
www.jhaccp.com.cn

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415955.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mongoose 通过账号密码连接 Error: Password contains an illegal unescaped character

mongoose 远程连接,我的密码有乱七八糟的字符,报错Error: Password contains an illegal unescaped character 报错的 mongodb: mongodb://c666:buyaokan###ccav.com:27017/zh_db,改成下面,就好啦 mongodb: mongodb:// encodeURIComponent(…

android 省市区选择器

demo1链接:https://download.csdn.net/download/meixi_android/10819638 效果1——跳页全屏式地区选择器: demo2链接:https://download.csdn.net/download/meixi_android/10823744 样式2——dialog市区选择器: 实现方法&#xf…

CCF - 201703-1 - 分蛋糕

问题描述 试题编号: 201703-1试题名称: 分蛋糕时间限制: 1.0s内存限制: 256.0MB问题描述:   小明今天生日,他有n块蛋糕要分给朋友们吃,这n块蛋糕(编号为1到n&#…

mongoose Topology was destroyed 处理

在用 node 的 mongoose 模块操作 mongodb 数据库的时候,本来正常返回数据,但是有时候会返回空白页,控制台里报错: Topology was destroyed数据库连接代码如下: var mongoose require(mongoose); mongoose.connect(m…

windows 下oracle 数据库 rman 备份

明确目标编写rman批处理文件 目标: A 每天夜间2点执行备份 B数据库全备,同时备份控制文件及归档日志文件,备份文件保存至:F:\backup\目录下,并在完成归档日志文件备份后,自动删除已备份的归档日志&#xff…

android xml 解析

创建xml 文件 <root><province name"安徽省"><city name"安庆市"><district name"枞阳县" zipcode"246000" /><district name"大观区" zipcode"246000" /><district name"…

js触发点击事件

最简单的触发单击事件肯定是elem.click()&#xff0c;平时在不需要考虑兼容性的场合我都是这么干的&#xff0c;但是毕竟这个方法有兼容性&#xff08;具体兼容性如何没做过测试&#xff09;&#xff0c;所以还是要掌握一个通用的方法。 以下代码是网上比较容易找到的一段代码&…

MacOS 升级后出现 xcrun: error: invalid active developer path, missing xcrun

升级macOS mojove&#xff0c;终端里使用git的时候&#xff0c;弹出一行莫名其妙的错误&#xff1a; xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun解决方法&am…

windows系统下oracle数据库rman备份记录(实战篇)

在windows 2003系统中装了oracle10G数据库&#xff0c;同时建了多个实例&#xff0c;这个备份应该怎么做呢&#xff1f; 在网上查了N多的资料&#xff0c;终于了解了一些&#xff1a; 冷备&#xff1a;把数据库已执行关闭后&#xff0c;对数据库做全备&#xff1b;需要停机&…

mac mongodb 安装

1、进入目录 cd /usr/local2、下载对应版本 sudo curl -O https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.3.tgz3、解压到当前目录 sudo tar -zxvf mongodb-osx-x86_64-3.4.2.tgz4、重命名为mongodb&#xff0c;主要是方便管理 sudo mv mongodb-osx-x86_64-4.…

format 参数说明

oracle 数据库中&#xff0c;可以用format参数是指定备份集的文件名格式 使用FORMAT参数时可使用的各种替换变量&#xff0c;如下&#xff1a; %c&#xff1a;备份片的拷贝数(从1开始编号)&#xff1b; %d&#xff1a;数据库名称&#xff1b; %D&#xff1a;位于该月中的天数 (…

【自动化__持续集成】___java___XML__DOM4操作

一、代码如下 package com.wujianbo.five;import java.io.File; import java.io.FileOutputStream; import java.util.List;import javax.annotation.Generated; import javax.swing.text.html.HTMLDocument.Iterator;import org.dom4j.Document; import org.dom4j.DocumentHel…

android 获取系统时间的时间戳 ,时间戳日期互转,计算日期时间差,获取明天日期,比较时间大小

long creatTimemBindCheck.remainPaymentTime; int shi (int)mBindCheck.remainPaymentTime/(3600*1000); int yu1 (int)mBindCheck.remainPaymentTime%(3600*1000); int fen (int)yu1/(60*1000); int yu2 (int)yu1%(60*1000); int mia (int)yu2/1000; 获取系统时间戳 pub…

mac 下载的破解软件显示 文件已损坏

其实&#xff0c;这是mac系统加强了安全机制&#xff0c;默认不允许用户自行下载安装应用程序&#xff0c;只能从Mac App Store里安装应用。 1、执行下面命令 sudo spctl --master-disable2、打开系统偏好设置 安全性与隐私&#xff0c;若显示任何来源&#xff0c;大功告成

rman全备时,配置项如何设置?

rman 全备设置哪些配置呢&#xff1f;如果是小库的话 下面这些就差不多了。。 CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO %F; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO %F; # defa…

【VBA】多条件去重

Function kaidan(txt)Dim i As IntegerDim arrSet d CreateObject("scripting.dictionary")For i 1 To Worksheets("汇-销").Range("a65536").End(xlUp).Rowarr Worksheets("汇-销").Range("a1:s" & i).Value If arr…