前提:進行資料表空間傳輸需要使用者有SYSDBA的系統許可權,被移動的資料表空間是自包含的資料表空間,不應有依賴於資料表空間外部對象的對象存在。確定是否自包含可使用系統包DBMS_TTS中的TRANSPORT_SET_CHECK過程進行檢查
例如要對錶空間OLTP進行傳輸,
SQL> exec dbms_tts.transport_set_check('OLTP',true,true);
PL/SQL procedure successfully completed.
SQL> select * from transport_set_violations;
no rows selected
如果有違返自包含,則會在表TRANSPORT_TABLESPACE_SET_VIOLATIONS視圖,如果沒有則裡面沒有資料。no rows selected shows the oltp tablespace
is not self-contained.
第一步:資料表空間變為唯讀
將來源資料庫中移動資料表空間設為唯讀狀態
SQL> alter tablespace oltp read only;
第二步:來源資料庫進行匯出操作
$expdp userid=system/oracle directory=my_test dumpfile=oltp.dump transport_tablespaces='oltp'
第三步:把dump檔案和資料表空間的資料庫檔案scp到目標主機上
第四步:目的資料庫進行匯入
$impdp userid=system/oracle directory=my_test dumpfile=oltp.dump transport_datafiles='u01/app/oracle/oradata/OMS/oltp01.dbf'
第五步:將源、目的資料庫的資料表空間狀態由唯讀改為可讀寫
ALTER
TABLESPACE OLTP READ WRITE;