oracle的sql loader資料載入工具

來源:互聯網
上載者:User

SQL*LOADER是ORACLE的資料載入工具,通常用來將作業系統檔案遷移到ORACLE資料庫中。SQL*LOADER是大型資料

倉庫選擇使用的載入方法。

在NT下,SQL*LOADER的命令為SQLLDR,在UNIX下一般為sqlldr/sqlload。

如執行:d:/oracle>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 -- 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)

commit_discontinued -- commit loaded rows when load is discontinued(預設FALSE)

更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

  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' 的位置正確。

控制檔案介紹

LOAD DATA

INFILE 't.dat' // 要匯入的檔案

// INFILE 'tt.date' // 匯入多個檔案

// INFILE * // 要匯入的內容就在control檔案裡 下面的BEGINDATA後面就是匯入的內容, *和't.dat'不能同時存在

INTO TABLE table_name // 指定裝入的表

BADFILE 'c:bad.txt' // 指定壞檔案地址

************* 以下是4種裝入表的方式

APPEND // 原先的表有資料 就加在後面

// INSERT // 裝載空表 如果原先的表有資料 sqlloader會停止 預設值

// REPLACE // 原先的表有資料 原先的資料會全部刪除

// TRUNCATE // 指定的內容和replace的相同 會用truncate語句刪除現存資料

************* 指定的TERMINATED可以在表的開頭 也可在表的內部欄位部分

FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'

// 裝載這種資料: 10,lg,"""lg""","lg,lg"

// 在表中結果: 10 lg "lg" lg,lg

// TERMINATED BY X '09' // 以十六進位格式 '09' 表示的

// TERMINATED BY WRITESPACE // 裝載這種資料: 10 lg lg

TRAILING NULLCOLS ************* 表的欄位沒有對應的值時允許為空白

************* 下面是表的欄位

(

col_1 , col_2 ,col_filler FILLER // FILLER 關鍵字 此列的數值不會被裝載

// 如: lg,lg,not 結果 lg lg

)

// 當沒聲明FIELDS TERMINATED BY ',' 時

// (

// col_1 [interger external] TERMINATED BY ',' ,

// col_2 [date "dd-mon-yyy"] TERMINATED BY ',' ,

// col_3 [char] TERMINATED BY ',' OPTIONALLY ENCLOSED BY 'lg'

// )

// 當沒聲明FIELDS TERMINATED BY ','用位置告訴欄位裝載資料

// (

// col_1 position(1:2),

// col_2 position(3:10),

// col_3 position(*:16), // 這個欄位的開始位置在前一欄位的結束位置

// col_4 position(1:16),

// col_5 position(3:10) char(8) // 指定欄位的類型

// )

看暈了吧?呵呵,我一開始也看得暈暈的,那就從我的執行個體開始吧!

這裡,我的作業系統是xp,資料庫主機是unix,資料庫是oracle 10g。現要將我的機器裡的文字檔datafile.txt匯入到遠端資料庫中,

現在檔案裡的記錄數達幾千萬。

datafile.txt常值內容:

js1a,192.168.2.254:80:,RUNNING

other,192.168.2.254:80:test.com,STOPPED

third,192.168.2.254:81:thirdabc.com,RUNNING

……

從中,我們看出有3列,分別以逗號分隔,為變長字串。

首先,我們現在資料庫建好表

create table mydata

(

mac_name varchar2(10),

mac_ip varchar2(50),

status varchar2(10)

)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.