天天看點

expdp檔案split再cat後impdp

       今天在Maclean的oracle群裡看到有個家夥說,expdp 的檔案split 再cat 之後 導不進資料庫,下面是我的實驗結果

注:資料庫的使用者名是demo_ls 隻有一張表  總的大小不超過1M

$sqlplus / as sysdba

建目錄,為資料泵導出

SQL>create directory dmpdir as '/oracle/dmp';

SQL> grant read on directory dmpdir to demo_ls;

資料泵導出

$expdp demo_ls DUMPFILE=expdpdemo.dmp directory=dmpdir schemas=demo_ls;

分割

$split -b 330k expdpdemo.dmp expdpdemo_

此時可以看到在/oracle/dmp目錄有多個檔案如expdpdemo_a*

合并

$cat expdpdemo_* > expdpdemo_new.dmp

再導入資料庫

$./impdp crmii/abs directory=dmpdir dumpfile=expdpdemo_new.dmp table_exists_action=replace 

- - relpace 表示當表存在時,先drop,再create。

    還有三個選項,分别是 skip(default),append   追加資料   truncate  先清空表,再插入資料

導入時有一個錯誤,是使用者名demo_ls已存在,先删除使用者 drop user demo_ls cascade 再impdp 完全沒問題。

另外再試expdp/impdp之前也試了exp/imp,分割再分離,也沒有問題。

由于資料量較小,測試可能不充分,但我想在大資料量下,這麼分割再合并是沒有問題

再試了一次,把一個10G左右的庫expdp(不到10分鐘),分割,再合并,發現與原檔案的大小一樣,

$diff -c crmii.dmp crmii_new.dmp

兩則沒有不同之處,是以分割再合并之後,可以正常導入