impdp默認導入expdp的dmp文件時,是需要建立相同名稱的表空間及臨時表空間的;而且會自動創建相同名稱的用戶名。
但是有時候我們想更改這種默認設置,這個時候就要用到impdp的特殊參數remap_schema(更改用戶名)及remap_tablespace(更改存儲表空間);
假設我們有一個example.dmp文件,原來用戶為olduser,存儲空間為example,example_temp;
我們需要更改用戶名及存儲表空間導入到新的庫中,只需要按照如下步驟進行:
1、建立新的表空間(假設名稱:newtablespace)及臨時表空間(假設名稱:newtablespace_temp),語句如下
--表空間
create tablespace newtablespace
logging
datafile 'D:\app\Administrator\oradata\newtablespace.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
--臨時表空間
create temporary tablespace newtablespace_temp
tempfile 'D:\app\Administrator\oradata\newtablespace_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
--注:具體參數及參數值根據實際情況調整。
2、建立用戶(此步驟可省略)
create user newuser identified by admin
default tablespace newtablespace
temporary tablespace newtablespace_temp;
3、導入
在oracle服務器cmd執行如下命令:
impdp system/admin@DNACLIENT directory=DATA_PUMP_DIR dumpfile=example.DMP REMAP_SCHEMA=olduser:newuser remap_tablespace=EXAMPLE:newtablespace,EXAMPLE_TEMP:newtablespace_temp
注:
1、此處directory使用了系統自帶的,如果需要自定義,請使用 create directory命令創建;
2、remap_tablespace多個表空間轉換用逗號隔開。
完成以上步驟,通過plsql利用newuser登錄數據庫,可以查看到newuser下的所有導入的表已轉入newtablespace表空間了。
mark一下,供以后查看。