国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

學習oracle sql loader 的使用

2024-08-29 13:29:41
字體:
來源:轉載
供稿:網友

學習oracle sql loader 的使用

一:sql loader 的特點
oracle自己帶了很多的工具可以用來進行數據的遷移、備份和恢復等工作。但是每個工具都有自己的特點。
 比如說exp和imp可以對數據庫中的數據進行導出和導出的工作,是一種很好的數據庫備份和恢復的工具,因此主要用在數據庫的熱備份和恢復方面。有著速度快,使用簡單,快捷的優點;同時也有一些缺點,比如在不同版本數據庫之間的導出、導入的過程之中,總會出現這樣或者那樣的問題,這個也許是oracle公司自己產品的兼容性的問題吧。
 sql loader 工具卻沒有這方面的問題,它可以把一些以文本格式存放的數據順利的導入到oracle數據庫中,是一種在不同數據庫之間進行數據遷移的非常方便而且通用的工具。缺點就速度比較慢,另外對blob等類型的數據就有點麻煩了。
 
二:sql loader 的幫助

c:/>sqlldr

sql*loader: release 9.2.0.1.0 - production on 星期六 10月 9 14:48:12 2004

copyright (c) 1982, 2002, oracle corporation.  all rights reserved.


用法: 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)

please note: 命令行參數可以由位置或關鍵字指定
。前者的例子是 'sqlload
scott/tiger foo'; 后一種情況的一個示例是 'sqlldr control=foo
userid=scott/tiger'.位置指定參數的時間必須早于
但不可遲于由關鍵字指定的參數。例如,
允許 'sqlldr scott/tiger control=foo logfile=log', 但是
不允許 'sqlldr scott/tiger control=foo log', 即使
參數 'log' 的位置正確。

c:/>

三: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,username,password,sj)   -----定義列對應順序
 
a、insert,為缺省方式,在數據裝載開始時要求表為空
b、append,在表中追加新記錄
c、replace,刪除舊記錄,替換成新裝載的記錄
d、truncate,同上
 
在dos窗口下使用sql*loader命令實現數據的輸入
 
c:/>sqlldr userid=system/manager control=input.ctl
  默認日志文件名為:input.log
默認壞記錄文件為:input.bad
 
2.還有一種方法
可以把excel文件另存為csv(逗號分隔)(*.csv),控制文件就改為用逗號分隔
load data
infile 'd:/car.csv'
append  into table t_car_temp
fields terminated by ","
(phoneno,vip_car)

b)在控制文件中直接導入數據

1、控制文件test.ctl的內容
-- the format for executing this file with sql loader is:
-- sqlldr control=<filename> be sure to substitute your
-- version of sql loader and the filename for this file.
load data
infile *
badfile 'c:/documents and settings/jackey/桌面/wmcountry.bad'
discardfile 'c:/documents and settings/jackey/桌面/wmcountry.dsc'
insert into table emccountry
fields terminated by ";" optionally enclosed by '"'
(
  countryid nullif (countryid="null"),
  countrycode,
  countryname,
  continentid nullif (continentid="null"),
  mapid nullif (mapid="null"),
  createtime date "mm/dd/yyyy hh24:mi:ss" nullif (createtime="null"),
  lastmodifiedtime date "mm/dd/yyyy hh24:mi:ss" nullif (lastmodifiedtime="null")
)
begindata
1;"jp";"japan";1;9;"09/16/2004 16:31:32";null
2;"cn";"china";1;10;"09/16/2004 16:31:32";null
3;"in";"india";1;11;"09/16/2004 16:31:32";null
4;"au";"australia";6;12;"09/16/2004 16:31:32";null
5;"ca";"canada";4;13;"09/16/2004 16:31:32";null
6;"us";"united states";4;14;"09/16/2004 16:31:32";null
7;"mx";"mexico";4;15;"09/16/2004 16:31:32";null
8;"gb";"united kingdom";3;16;"09/16/2004 16:31:32";null
9;"de";"germany";3;17;"09/16/2004 16:31:32";null
10;"fr";"france";3;18;"09/16/2004 16:31:32";null
11;"it";"italy";3;19;"09/16/2004 16:31:32";null
12;"es";"spain";3;20;"09/16/2004 16:31:32";null
13;"fi";"finland";3;21;"09/16/2004 16:31:32";null
14;"se";"sweden";3;22;"09/16/2004 16:31:32";null
15;"ie";"ireland";3;23;"09/16/2004 16:31:32";null
16;"nl";"netherlands";3;24;"09/16/2004 16:31:32";null
17;"dk";"denmark";3;25;"09/16/2004 16:31:32";null
18;"br";"brazil";5;85;"09/30/2004 11:25:43";null
19;"kr";"korea, republic of";1;88;"09/30/2004 11:25:43";null
20;"nz";"new zealand";6;89;"09/30/2004 11:25:43";null
21;"be";"belgium";3;79;"09/30/2004 11:25:43";null
22;"at";"austria";3;78;"09/30/2004 11:25:43";null
23;"no";"norway";3;82;"09/30/2004 11:25:43";null
24;"lu";"luxembourg";3;81;"09/30/2004 11:25:43";null
25;"pt";"portugal";3;83;"09/30/2004 11:25:43";null
26;"gr";"greece";3;80;"09/30/2004 11:25:43";null
27;"il";"israel";1;86;"09/30/2004 11:25:43";null
28;"ch";"switzerland";3;84;"09/30/2004 11:25:43";null
29;"a1";"anonymous proxy";0;0;"09/30/2004 11:25:43";null
30;"a2";"satellite provider";0;0;"09/30/2004 11:25:43";null
31;"ad";"andorra";3;0;"09/30/2004 11:25:43";null
32;"ae";"united arab emirates";1;0;"09/30/2004 11:25:43";null
33;"af";"afghanistan";1;0;"09/30/2004 11:25:43";null
34;"ag";"antigua and barbuda";7;0;"09/30/2004 11:25:43";null
35;"ai";"anguilla";7;0;"09/30/2004 11:25:43";null
36;"al";"albania";3;0;"09/30/2004 11:25:43";null
37;"am";"armenia";3;0;"09/30/2004 11:25:43";null
38;"an";"netherlands antilles";3;0;"09/30/2004 11:25:43";null
39;"ao";"angola";2;0;"09/30/2004 11:25:43";null
40;"ap";"asia/pacific region";2;0;"09/30/2004 11:25:43";null
41;"aq";"antarctica";8;0;"09/30/2004 11:25:43";null
42;"ar";"argentina";5;0;"09/30/2004 11:25:43";null
43;"as";"american samoa";6;0;"09/30/2004 11:25:43";null
44;"aw";"aruba";5;0;"09/30/2004 11:25:43";null
45;"az";"azerbaijan";1;0;"09/30/2004 11:25:43";null
46;"ba";"bosnia and herzegovina";3;0;"09/30/2004 11:25:43";null
47;"bb";"barbados";5;0;"09/30/2004 11:25:43";null
48;"bd";"bangladesh";1;0;"09/30/2004 11:25:43";null
49;"bf";"burkina faso";2;0;"09/30/2004 11:25:43";null
50;"bg";"bulgaria";3;0;"09/30/2004 11:25:43";null
51;"bh";"bahrain";1;0;"09/30/2004 11:25:43";null
52;"bi";"burundi";2;0;"09/30/2004 11:25:43";null
53;"bj";"benin";2;0;"09/30/2004 11:25:43";null
54;"bm";"bermuda";4;0;"09/30/2004 11:25:43";null
55;"bn";"brunei darussalam";1;0;"09/30/2004 11:25:43";null
56;"bo";"bolivia";5;0;"09/30/2004 11:25:43";null
57;"bs";"bahamas";7;0;"09/30/2004 11:25:43";null
58;"bt";"bhutan";1;0;"09/30/2004 11:25:43";null
59;"bv";"bouvet island";5;0;"09/30/2004 11:25:43";null
60;"bw";"botswana";2;0;"09/30/2004 11:25:43";null
61;"by";"belarus";3;0;"09/30/2004 11:25:43";null
2、執行導入命令
c:/>sqlldr userid=system/manager control=test.ctl

c)復雜格式的導入


上一篇:在Linux下安裝Oracle9i

下一篇:oracle筆記

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陕西省| 永泰县| 大港区| 芜湖县| 剑川县| 白河县| 保靖县| 栾城县| 柳江县| 西城区| 连江县| 调兵山市| 万全县| 桂林市| 抚州市| 沾益县| 长治县| 浦江县| 横山县| 贵阳市| 吉安市| 铁岭县| 历史| 三门峡市| 富裕县| 丹寨县| 澎湖县| 封丘县| 蕲春县| 蓝山县| 古蔺县| 大理市| 德兴市| 石楼县| 两当县| 淅川县| 凯里市| 肃宁县| 江源县| 莱芜市| 岳阳市|