日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

oracle sqlldr

 昵稱3080113 2013-08-15
最近需弄批量導(dǎo)入數(shù)據(jù),別人只給了我一個(gè)ctl的控制文件,自己就琢磨了下怎么用
1、創(chuàng)建表ua_test存放需導(dǎo)入的數(shù)據(jù),sql如下:
create table ua_test
(ad_space_id number not null,
os_type varchar2(40),
ad_format varchar2(40));
2、需要導(dǎo)入的數(shù)據(jù)文件先建好,命名: ua_import.txt,數(shù)據(jù)如下
82532|iphone|banner
81591|android|fullscreen
90568|iphone|banner
82571|ipad|vedio
3、控制文件:import_control.ctl
Load data                                                     --1、控制文件標(biāo)識(shí)
infile 'D:\ImportData\ua_import.txt'            --2、要輸入的數(shù)據(jù)文件名為ua_import.txt
Append into table ua_test                         --3、向表ua_test中追加記錄
FIELDS TERMINATED BY '|'                    --4、ua_import.txt文件的內(nèi)容以'|'分隔,字段終止于空行
TRAILING NULLCOLS
(
id,
os_type,
format
)                                                                   --定義列對應(yīng)順序
其中append為數(shù)據(jù)裝載方式,還有其他選項(xiàng):
ainsert,為缺省方式,在數(shù)據(jù)裝載開始時(shí)要求表為空
b、append,在表中追加新記錄
c、replace,刪除舊記錄(全部的記錄),替換成新裝載的記錄
d、truncate,同上先刪除再新增

4、import_control.ctl和ua_import.txt放在d盤的同一個(gè)目錄里,
sqlldr userid=DataSource@數(shù)據(jù)庫用戶名/數(shù)據(jù)庫密碼 control='D:\ImportData\import_control.ctl' data='D:\ImportData\ua_import.txt' log='D:\ImportData\ua_test.log'

5. sqlldr用到的主要參數(shù)(參考別人寫的)
1) userid -- ORACLE username/password
2) control –控制文件
3) log –記錄的日志文件
4) bad –壞數(shù)據(jù)文件,記錄錯(cuò)誤的未加載數(shù)據(jù)
5) data –數(shù)據(jù)文件,* data參數(shù)只能指定一個(gè)數(shù)據(jù)文件,如果控制文件也通過infile指定了數(shù)據(jù)文件,并且指定多個(gè),sqlldr在執(zhí)行時(shí),先加載data參數(shù)指定的數(shù)據(jù)文件,控制文件中第一個(gè)infile指定的數(shù)據(jù)文件被忽略,但后續(xù)的infile指定的數(shù)據(jù)文件繼續(xù)有效
6) discard –丟棄的數(shù)據(jù)文件
7) discardmax –允許丟棄數(shù)據(jù)的最大值 (默認(rèn)全部)
8) skip --跳過記錄數(shù),從數(shù)據(jù)文件中,從第一行開始要計(jì)算要跳過的行數(shù) (默認(rèn)0)
9) load -- Number of logical records to load (默認(rèn)全部)
10) errors –允許的錯(cuò)誤記錄數(shù),超過則終止任務(wù)(默認(rèn)50)
11) rows -- Number of rows in conventional path bind array or between direct path data saves(每次提交的記錄數(shù),默認(rèn):常規(guī)路徑64,直接路徑全部,所以使用直接路徑的話,效率會(huì)比普通的好太多太多)
12) bindsize -- Size of conventional path bind array in bytes每次提交記錄的緩沖區(qū)的大小,字節(jié)為單位,默認(rèn)256000)
13) silent --禁止輸出信息(header,feedback,errors,discards,partitions)
14) direct –使用直通路徑方式導(dǎo)入(默認(rèn)FALSE)
如果表中有索引的話,是不能指定direct=TRUE,除非使用skip_index_maintenance=TRUE,這個(gè)就是在導(dǎo)入的時(shí)候忽略索引,所以在數(shù)據(jù)導(dǎo)入完畢以后,查看索引的狀態(tài)應(yīng)該都是無效的,需要重建之,如下SQLselect * from dba_indexes where table_name='?' ;
alter idnex index_name rebuild ;
重新建立索引要比新建索引快。
15) parallel --并行導(dǎo)入 (默認(rèn)FALSE,注意:parallel并不是讓一個(gè)sqlldr語句起多個(gè)進(jìn)程來加載數(shù)據(jù),而是不鎖住加載表,允許別的直接路徑加載.所以要使parallel起作用,應(yīng)該先將要加載的數(shù)據(jù)文件分成多個(gè),用多個(gè)sqlldr語句同時(shí)加載,如下例:
sqlldr userid=scott/tiger control=load1.ctl data=data1.txt direct=y parallel=true & sqlldr userid=scott/tiger control=load2.ctl data=data2.txt direct=y parallel=true & sqlldr userid=scott/tiger control=load3.ctl data=data3.txt direct=y parallel=true &)
16) skip_unusable_indexes -- disallow/allow unusable indexes or index partitions(默認(rèn)FALSE)
17) skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable(默認(rèn)FALSE)


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多