RECORDLENGTH=65535(64KB 最大 I/O 緩衝)。exp userid=system/manager full=y direct=y recordlength=65535 file=exp_full.dmp log=exp_full.log
# Unix/Linux
mknod /tmp/exp_pipe p
compress < /tmp/exp_pipe > export.dmp.Z &
exp file=/tmp/exp_pipe ...
傳統 Exp 不支援並行,**強烈建議改用 Data Pump (expdp/impdp)** 並行度 PARALLEL=4 以上,效能指數級提升。
| 技巧 | 參數/作法 | 效益 | 適用場景 |
|---|---|---|---|
| 管道解壓縮 | mknod /tmp/imp_pipe p; uncompress < export.dmp.Z > /tmp/imp_pipe &; imp file=/tmp/imp_pipe | 省解壓時間、無臨時檔 | 大檔案匯入 |
| 避開 I/O 尖峰 | 非上班時間、停用批次 Job | 減少磁碟爭用 | 生產環境緊急恢復 |
| 擴大排序區 | 8i: sort_area_size 調大 5-10 倍;9i+: pga_aggregate_target 調至 1-2GB | 索引建立在記憶體排序,避免磁碟排序 (慢 14,000 倍) | 大表索引重建 |
| 調大 BUFFER | BUFFER=10240000 (10MB) | 減少讀取 DMP 系統呼叫次數 | 所有匯入 |
| 逐筆 Commit | COMMIT=Y | 減少 Undo 產生、避免長交易阻塞 | 大量資料匯入 |
| 延後建立索引 | INDEXES=N 匯入資料 → 手動建索引或二次 INDEXES=Y ROWS=N | 匯入階段專注資料寫入,索引可平行建立 | 超大表、維護窗口有限 |
| MTS 大池調大 | 共享伺服器模式下 LARGE_POOL_SIZE=150M | 避免 MTS 共用記憶體不足導致 Exp/Imp 失敗 | 啟用 MTS 環境 |
# 階段 1:僅匯入資料
imp user2/pwd fromuser=user1 touser=user2 file=/tmp/imp_pipe \
commit=y feedback=10000 buffer=10240000 ignore=y rows=y indexes=n
# 階段 2:僅匯入索引 (資料已存在)
imp user2/pwd fromuser=user1 touser=user2 file=/tmp/imp_index_pipe \
commit=y feedback=10000 buffer=10240000 ignore=y rows=n indexes=y
SQL> SELECT DISTINCT server FROM v$session;
-- 出現 SHARED 或 NONE 表示啟用 MTS
Oracle 10g 起推出 **Data Pump (expdp/impdp)**,支援並行、網路模式、互動式指令、細粒度物件過濾、壓縮/加密、可重啟作業。所有新專案**務必使用 Data Pump**,傳統 Exp/Imp 僅作為舊版本相容或極簡單匯出之用。