取得說明
exp help=y
imp help=y
三種操作介面
| 介面 | 語法 | 適用場景 |
| 互動式 | exp 依提示輸入 | 臨時、少參數 |
| 命令列 | exp user/pwd@db file=/dir/xxx.dmp full=y | 腳本自動化、排程 |
| 參數檔 | exp parfile=xxx.par | 參數多、需版控、跨環境復用 |
參數檔範例 user.par:
userid=user/pass
buffer=8192000
compress=n
grants=y
file=/oracle/test.dmp
full=y
三種導出模式
| 模式 | 導出範圍 | 導出範例 | 導入範例 |
| 表級 | 指定表 | exp u/p file=t.dmp tables=t1,t2
exp u/p file=t.dmp tables=t1 query="where col='val'" | imp u/p file=t.dmp tables=t1,t2 fromuser=u touser=v commit=y ignore=y |
| 用戶級 | 指定用戶所有物件 | exp u/p file=u.dmp owner=(u1,u2)
exp u/p file=obj.dmp owner=u rows=n(僅結構) | imp u/p file=u.dmp fromuser=u1 touser=v commit=y ignore=y |
| 全庫級 | 所有用戶、系統物件 | exp u/p file=full.dmp full=y | imp u/p file=full.dmp full=y commit=y ignore=y |
關鍵參數速查
| 參數 | 說明 | 典型值 |
BUFFER | 資料緩衝區大小(bytes),影響效能 | 8192000 (8MB) |
COMPRESS | 是否將 extent 合併為單一 initial extent(導入時) | N(保留原儲存結構) |
GRANTS | 是否導出授權 | Y |
INDEXES | 是否導出索引 | Y |
ROWS | 是否導出資料列 | Y(N 僅結構) |
CONSISTENT | 導出時是否使用 READ ONLY 一致性視圖(需 UNDO 空間) | Y(生產庫建議) |
STATISTICS | 導出統計資訊 | ALWAYS / NONE |
FLASHBACK_SCN / FLASHBACK_TIME | 導出一致性 SCN/時間點(10g+) | 替代 CONSISTENT=Y |
QUERY | 表級導出時的 WHERE 子句 | "where dt > sysdate-7" |
VOLSIZE | 磁帶/裸裝置卷大小(KB) | 2048000 (2GB) |
導入常用組合
imp system/manager file=full.dmp full=y ignore=y commit=y
imp user/pass file=u.dmp fromuser=olduser touser=newuser ignore=y commit=y
imp user/pass file=t.dmp tables=t1,t2 ignore=y commit=y
IGNORE=Y:忽略建立錯誤(如表已存在),繼續載入資料。
COMMIT=Y:每陣列提交,減少 UNDO 消耗,避免大交易回滾。
DESTROY=Y(僅 IMP):覆蓋現有資料檔(慎用)。
遷移檢查清單
- 來源/目標版本相容性(
exp 版本 ≤ 目標 DB 版本)。
- 字元集一致或可轉換(
NLS_LANG 設定)。
- 目標表空間足夠、配額授權。
- 導入前關閉觸發器/約束/索引(大量載入),導入後重建。
- 導入後驗證:行數比對、PK/UK 檢查、應用煙霧測試。