Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > 使用SQL*LOADER装载数据
【标  题】:使用SQL*LOADER装载数据
【关键字】:SQL,LOADER
【来  源】:http://blog.csdn.net/Hunterdiary/archive/2007/03/06/1522267.aspx

使用SQL*LOADER装载数据

Your Ad Here

一:SQL*LOADER的特点

oracle自己带了很多的工具可以用来进行数据的迁移、备份和恢复等工作。但是每个工具都有自己的特点。
 比如说exp和imp可以对数据库中的数据进行导出和导出的工作,是一种很好的数据库备份和恢复的工具,因此主要用在数据库的热备份和恢复方面。有着速度快,使用简单,快捷的优点;同时也有一些缺点,比如在不同版本数据库之间的导出、导入的过程之中,总会出现这样或者那样的问题,这个也许是oracle公司自己产品的兼容性的问题吧。
 SQL*LOADER工具却没有这方面的问题,它可以把一些以文本格式存放的数据顺利的导入到oracle数据库中,是一种在不同数据库之间进行数据迁移的非常方便而且通用的工具。缺点就速度比较慢,另外对blob等类型的数据就有点麻烦了。

二:SQL*LOADER的帮助

用法: SQLLDR keyword=value [,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(默认256000)
    silent -- Suppress 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 unus
able(默认FALSE)
  readsize -- Size of Read buffer                (默认1048576)
external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE(
默认NOT_USED)
columnarrayrows -- Number of rows for direct path column array(默认5000)
streamsize -- Size of direct path stream buffer in bytes(默认256000)
multithreading -- use multithreading in direct path
 resumable -- enable or disable resumable for current session(默认FALSE)
resumable_name -- text string to help identify resumable statement
resumable_timeout -- wait time (in seconds) for RESUMABLE(默认7200)
date_cache -- size (in entries) of date conversion cache(默认1000)

三:SQL*LOADER使用例子
a)SQLLoader将 Excel 数据导出到 Oracle
1.创建SQL*LOADER输入数据所需要的文件,均保存到C:\,用记事本编辑:
控制文件: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,name,birthday date "yyyy/mm/dd HH24:mi:ss",other) -----定义列对应顺序 
  
 2.还有一种方法
    可以把EXCEL文件另存为CSV(逗号分隔)(*.csv),控制文件就改为用逗号分隔 :
     load data                  --1、控制文件标识
  infile 'test.csv'                  --2、要输入的数据文件名为test.csv
  append into table test     --3、向表test中追加记录
  fields terminated by ','         --4、字段终止于','
  (id,name,birthday date "yyyy/mm/dd HH24:mi:ss",other) -----定义列对应顺序 

  注意:birthday为日期类型,如:2007/01/01 12:12:12 其输入格式:date "yyyy/mm/dd HH24:mi:ss" ,如果没有时分秒的则不需要格式化

a、insert,   为缺省方式,在数据装载开始时要求表为空
b、append,在表中追加新记录
c、replace, 删除旧记录,替换成新装载的记录
d、truncate,同上 

 b)在建立一个BAT文件:sqlload.bat,其内容如下:
如果是本地服务器:
sqlldr userid=system/manager control=input.ctl rows=100 bindsize=1000000
如果是远程或者本地连接字有多个:
sqlldr userid=system/manager@mydemo control=input.ctl rows=100 bindsize=1000000

c)在DOS窗口下实现数据的输入
 
C:\>sqlload 
默认日志文件名为:input.log
默认坏记录文件为:test.bad 

 


 

数据备份中可能出错的情况及解决办法:【上一篇】
解析oracle的rownum:【下一篇】
【相关文章】
  • 如何在SQL SERVER 2005中复制数据库
  • 求救 SQL server 2000安装问题
  • asp防SQL注入程序优化版本
  • Mysql分页查询通用存储过程
  • 删除SQL数据库中事务日志方法
  • mysql存储过程及c#调用标准版
  • 分页代码及相应SQL效率的分析(附:测试报告结果)
  • ibatis打印出底层执行的所有 Sql
  • 不要让SQLServer自动转换害了你!
  • 免费的SQL Server培训录像(以及其他好的数据教程的指针)
  • 【随机文章】
  • 在PL/SQL中使用随机数和GUID
  • Building a Chrooted sftp Environment on Linux
  • ComponentArt的Grid页面传值
  • LAMP是什么?
  • 交换机漏洞全面了解
  • diy pe教学1
  • C#重点知识详解(一)
  • Linux内核调整
  • 免费的web服务器日志分析程序webalizer
  • perl程序设计(四)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.