当前位置: 首页 > news >正文

[转载]---Oracle SQL Loader

一、SQL Loader的特点:

Oracle自己带了很多的工具可以用来进行数据的迁移、备份和恢复等工作。但是每个工具都有自己的特点。

比如说exp和imp可以对数据库中的数据进行导出和导入的工作,是一种很好的数据库备份和恢复的工具,因此主要用在数据库的热备份和恢复方面。有着速度快,使用简单,快捷的优点;同时也有一些缺点,比如在不同版本数据库之间的导出、导入的过程之中,总会出现这样或者那样的问题,这个也许是oracle公司自己产品的兼容性的问题。

sql*loader工具却没有这方面的问题。它可以把一些以文本格式存放的数据顺利的导入到oracle数据库中,是一种在不同数据库之间进行数据迁移的非常方便而且通用的工具。缺点就速度比较慢,另外对blob等类型的数据就有点麻烦了。

二、sqlldr帮助:

 1 [oracle@yft loader]$ sqlldr
 2 
 3 SQL*Loader: Release 11.2.0.1.0 - Production on Tue Feb 19 11:47:23 2013
 4 
 5 Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 6 
 7 
 8 Usage: SQLLDR keyword=value [,keyword=value,...]
 9 
10 Valid Keywords:
11 
12     userid -- ORACLE username/password(Oracle用户名/口令)           
13    control -- control file name(控制文件名)                  
14        log -- log file name(日志文件名)                      
15        bad -- bad file name(错误文件名)                      
16       data -- data file name(数据文件名)                     
17    discard -- discard file name(废弃文件名)                  
18 discardmax -- number of discards to allow(允许废弃的文件的数目)          (Default all)
19       skip -- number of logical records to skip(要跳过的逻辑记录的数目)    (Default 0)
20       load -- number of logical records to load(要加载的逻辑记录的数目)    (Default all)
21     errors -- number of errors to allow(允许的错误的数目)            (Default 50)
22       rows -- number of rows in conventional path bind array or between direct path data saves(常规路径绑定数组中或直接路径保存数据间的行数)
23                (Default: Conventional path 64, Direct path all)
24   bindsize -- size of conventional path bind array in bytes(常规路径绑定数组的大小)  (Default 256000)
25     silent -- suppress messages during run(运行过程中隐藏消息) (header,feedback,errors,discards,partitions)
26     direct -- use direct path(使用直接路径)                      (Default FALSE)
27    parfile -- parameter file: name of file that contains parameter specifications(参数文件:包含参数说明的文件的名称)
28   parallel -- do parallel load(执行并行加载)                     (Default FALSE)
29       file -- file to allocate extents from(要从以下对象中分配区的文件)      
30 skip_unusable_indexes -- disallow/allow unusable indexes or index partitions(不允许/允许使用无用的索引或索引分区)  (Default FALSE)
31 skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable(没有维护索引,将受到影响的索引标记为无用)  (Default FALSE)
32 commit_discontinued -- commit loaded rows when load is discontinued(提交加载中断时已加载的行)  (Default FALSE)
33   readsize -- size of read buffer(读取缓冲区的大小)                  (Default 1048576)
34 external_table -- use external table for load;(使用外部表进行加载) NOT_USED, GENERATE_ONLY, EXECUTE  (Default NOT_USED)
35 columnarrayrows -- number of rows for direct path column array(直接路径列数组的行数)  (Default 5000)
36 streamsize -- size of direct path stream buffer in bytes(直接路径流缓冲区的大小)  (Default 256000)
37 multithreading -- use multithreading in direct path(在直接路径中使用多线程)  
38  resumable -- enable or disable resumable for current session(启用或禁用当前的可恢复会话)  (Default FALSE)
39 resumable_name -- text string to help identify resumable statement(有助于标识可恢复语句的文本字符串)
40 resumable_timeout -- wait time (in seconds) for RESUMABLE(RESUMABLE的等待时间)  (Default 7200)
41 date_cache -- size (in entries) of date conversion cache(日期转换高速缓存的大小)  (Default 1000)
42 no_index_errors -- abort load on any index errors  (Default FALSE)
43 
44 PLEASE NOTE: Command-line parameters may be specified either by
45 position or by keywords.  An example of the former case is 'sqlldr
46 scott/tiger foo'; an example of the latter is 'sqlldr control=foo
47 userid=scott/tiger'.  One may specify parameters by position before
48 but not after parameters specified by keywords.  For example,
49 'sqlldr scott/tiger control=foo logfile=log' is allowed, but
50 'sqlldr scott/tiger control=foo log' is not, even though the
51 position of the parameter 'log' is correct.

 三、SQL LOADER实例:

 ----创建一个张测试表----
1
SQL> show user 2 USER is "JACK" 3 4 SQL> create table jack (id int,name varchar2(10)); 5 6 Table created. 7 ----控制文件内容----
8
[oracle@yft loader]$ cat input.ctl 9 load data 10 infile '/home/oracle/loader/jack.txt' 11 append into table jack 12 (id char terminated by ',', 13 name char terminated by whitespace) 14 ----数据文件内容----
15
[oracle@yft loader]$ cat jack.txt 16 1,aa 17 2,bb 18 3,cc 19 ----执行sqlldr命令,数据加载----
20
[oracle@yft loader]$ sqlldr userid=jack/jack control=input.ctl 21 22 SQL*Loader: Release 11.2.0.1.0 - Production on Tue Feb 19 12:48:29 2013 23 24 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. 25 26 Commit point reached - logical record count 3 27 28 ----查看日志文件中有没有报错----
29
[oracle@yft loader]$ cat input.log 30 31 SQL*Loader: Release 11.2.0.1.0 - Production on Tue Feb 19 12:48:29 2013 32 33 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. 34 35 Control File: input.ctl 36 Data File: /home/oracle/loader/jack.txt 37 Bad File: jack.bad 38 Discard File: none specified 39 40 (Allow all discards) 41 42 Number to load: ALL 43 Number to skip: 0 44 Errors allowed: 50 45 Bind array: 64 rows, maximum of 256000 bytes 46 Continuation: none specified 47 Path used: Conventional 48 49 Table JACK, loaded from every logical record. 50 Insert option in effect for this table: APPEND 51 52 Column Name Position Len Term Encl Datatype 53 ------------------------------ ---------- ----- ---- ---- --------------------- 54 ID FIRST * , CHARACTER 55 NAME NEXT * WHT CHARACTER 56 57 58 Table JACK: 59 3 Rows successfully loaded. 60 0 Rows not loaded due to data errors. 61 0 Rows not loaded because all WHEN clauses were failed. 62 0 Rows not loaded because all fields were null. 63 64 65 Space allocated for bind array: 33024 bytes(64 rows) 66 Read buffer bytes: 1048576 67 68 Total logical records skipped: 0 69 Total logical records read: 3 70 Total logical records rejected: 0 71 Total logical records discarded: 0 72 73 Run began on Tue Feb 19 12:48:29 2013 74 Run ended on Tue Feb 19 12:48:30 2013 75 76 Elapsed time was: 00:00:00.13 77 CPU time was: 00:00:00.03 78 ----验证数据是否已经加载进去----
79
SQL> select * from jack; 80 81 ID NAME 82 ---------- ---------- 83 1 aa 84 2 bb 85 3 cc

 

相关文章:

  • 开源,不代表你的线上产品可以免费试用
  • Docker(三)安装Mysql
  • 线程的两种创建方式
  • H5弹窗后原窗口不会被滑动
  • ZendStudio 常用快捷键大全
  • Diffie-hellman 密匙交换
  • 一段话系列-Spring cloud gateway都有哪些内置filter
  • 中俄蒙三国六方签订白鹤研究与保护合作备忘录
  • jS获取子、父、兄节点方法小结
  • quartz详细介绍
  • 回顾小程序2018年三足鼎立历程,2019年BAT火力全开
  • oschina
  • 深度学习入门:10门免费线上课程推荐
  • CF712E Memory and Casinos
  • 研究:印度气候变暖速度加剧 2040年或面临重灾
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • 【跃迁之路】【463天】刻意练习系列222(2018.05.14)
  • CSS相对定位
  • css属性的继承、初识值、计算值、当前值、应用值
  • C语言笔记(第一章:C语言编程)
  • interface和setter,getter
  • Java IO学习笔记一
  • javascript面向对象之创建对象
  • JS专题之继承
  • mysql外键的使用
  • PAT A1120
  • Python socket服务器端、客户端传送信息
  • Shell编程
  • 动手做个聊天室,前端工程师百无聊赖的人生
  • 对话 CTO〡听神策数据 CTO 曹犟描绘数据分析行业的无限可能
  • 浮现式设计
  • 构建二叉树进行数值数组的去重及优化
  • 盘点那些不知名却常用的 Git 操作
  • 三栏布局总结
  • 因为阿里,他们成了“杭漂”
  • 1.Ext JS 建立web开发工程
  • 组复制官方翻译九、Group Replication Technical Details
  • ​DB-Engines 12月数据库排名: PostgreSQL有望获得「2020年度数据库」荣誉?
  • ​软考-高级-信息系统项目管理师教程 第四版【第23章-组织通用管理-思维导图】​
  • $.ajax中的eval及dataType
  • (4)Elastix图像配准:3D图像
  • (6)添加vue-cookie
  • (delphi11最新学习资料) Object Pascal 学习笔记---第7章第3节(封装和窗体)
  • (Matlab)遗传算法优化的BP神经网络实现回归预测
  • (四)汇编语言——简单程序
  • (一)eclipse Dynamic web project 工程目录以及文件路径问题
  • (转)原始图像数据和PDF中的图像数据
  • (转载)PyTorch代码规范最佳实践和样式指南
  • .bashrc在哪里,alias妙用
  • .Net core 6.0 升8.0
  • .NET Core 和 .NET Framework 中的 MEF2
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .Net Remoting常用部署结构
  • .net 按比例显示图片的缩略图
  • .NET 简介:跨平台、开源、高性能的开发平台