oracle expdp impdp 的簡要說明

來源:互聯網
上載者:User

使用資料泵expdp,impdp可以在服務端完成資料的匯入、匯出,效率比較高
不用設定環境變數 NLS_LANG,預設會去資料庫的字元集


      create directory backup as '/backup';
      grant read,write on directory backup to scott;
1 基於資料庫的匯出、匯入
 
  a 資料庫全庫匯出
  expdp system/root directory=backup dumpfile=full.dmp logfile=full.log full=y

  b 整個庫匯入
  impdp system/root directory=backup dumpfile=full.dmp logfile=full2.log full=y

   #匯入某一個使用者的資料,schemas指定
  impdp system/root directory=backup dumpfile=full.dmp logfile=full2.log  schemas=scott

  impdp system/root directory=backup dumpfile=full.dmp logfile=full2.log  schemas=scott,gpecnew,hsj1

2 基於使用者(schema)的匯出、匯入(以scott使用者為例)

  a 將scott使用者的資料匯出
  grant read,write on directory backup to scott;
  expdp  scott/root directory=backup dumpfile=scott.dmp logfile=scott.log schemas=scott
  或者
  expdp  system/root directory=backup dumpfile=scott.dmp logfile=scott.log schemas=scott

  b 進行資料的匯入,對於與imp來說更簡單,不再需要建立使用者,只是需要建立資料表空間而已
  impdp system/root directory=backup dumpfile=scott.dmp logfile=scott2.log schemas=scott
  或者
  impdp system/root directory=backup dumpfile=scott.dmp logfile=scott2.log  full=y;
  或者
  impdp system/root directory=backup dumpfile=scott.dmp logfile=scott2.log

3 基於表的匯出、匯入 一次只能匯出一個方案的表資料
   a 匯出資料表 dept,emp

   expdp system/root directory=backup dumpfile=tables.dmp logfile=tables.log TABLES=scott.dept,scott.emp

   或者

   expdp scott/root directory=backup dumpfile=tables.dmp logfile=tables.log TABLES=dept,emp

  b  將資料檔案匯入進去
   impdp scott/root directory=backup dumpfile=tables.dmp logfile=tables2.log  (full=y);
   
4  基於使用者匯出表,排除以V開頭,Z開頭的所有表,排除 t_bd_person,t_bd_users


   a 匯出
   expdp hsj/hsj directory=backup dumpfile=hsj.dmp logfile=hsj.log schemas=hsj
   exclude=table:\" like \'V%\'\",table:\"like \'Z%\",table:\" in\(\'T_BD_PERSON',\'T_BD_USERS'\)\"

   或者使用parfile參數檔案 hsj.par
   userid=hsj/hsj
   directory=backup
   dumpfile=hsj.dmp
   logfile=hsj.log
   schemas=hsj
   exclude=table: " like  'V% ' ",table: "like  'Z% ",table: " in ( 'T_BD_PERSON', 'T_BD_USERS' ) "

   expdp parfile=hsj.par

   b 匯入
   impdp hsj/hsj directory=backup dumpfile=hsj.dmp logfile=hsj2.log
 
說明:對於include參數,暫時無法完成 以V開頭或者以Z開頭的表的條件的匯出,條件之間只能and,不能or
      對於expdp、impdp,我們需要制定directory參數,可以參考下面兩個語句
      create directory backup as '/backup';
      grant read,write on directory backup to scott;

相關文章

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.