SQL Loader 可以針對一些flat-file進行讀取,讀像些以符號(ex "," "|" )或空格分隔的檔案

將資料load進你的table裡,而這些讀取的方法是由control file(.ctl)所控制的,這邊介紹的是control file的四種load方法。

目前有四種Loading方法: INSERT、APPEND、REPLACE、TRUNCATE

INSERT:將資料讀進一個空table中,table內必須沒有資料,否則SQL loader將會提示error。

If the tables you are loading into are empty, use the INSERT option. It requires the table to be empty before loading. SQL*Loader terminates with an error if the table contains rows.

APPEND:將資料讀進一個table之中,不論table內有無資料,都將插入該table中。

If data already exists in the table, SQL*Loader appends the new rows to it. If data does not already exist, the new rows are simply loaded.

REPLACE:先對目標table做一個delete清空所有資料,再讀資料進table中。

all rows in the table are deleted and the new data is loaded.

TRUNCATE:先對目標table做一個truncate清空所有資料,再讀資料進table中。

TRUNCATE statement quickly and efficiently deletes all rows from a table or cluster, to achieve the best possible performance. 

 

INSERT選項是SQL loader的預設方法,若確認你的table是空的,就用這個吧!

使用APPEND,假設某資料有兩筆資料,第一次是插入了兩筆資料,再度執行一次將共有四筆資料在表格內。

至於REPLACE,則會觸發該表格的delete trigger,另外,若你稍微懂Oracle資料庫的架構,

也會觸發資料庫管理系統的undo、redo log file。

TRUNCATE很單純的清空資料表table,再讀進資料,由原文可以看出該選項對SQL loader及DB有最好的performance

因為不像REPLACE選項,會觸發一堆有的沒的,當然,這選項非常的暴力,叫DBA回復資料是件困難的事情...

但通常會使用SQL loader我想根本就沒想要復原這碼子事吧!!

 

Oracle的文件寫得很棒,若需要詳細的資訊可以去看看 「SQL*Loader Control File Reference」

arrow
arrow
    全站熱搜

    Wallace 發表在 痞客邦 留言(0) 人氣()