0、準備工作
--建立被傳輸的資料表空間
SQL> create tablespace tbs_single
datafile 'c:\Oracle\oradata\ora9i\tbs_single01.dbf' size 100M
extent management local;
--建立使用者,並將資料表空間作為預設資料表空間
SQL> create user tranp identified by oracle default tablespace tbs_single;
SQL> grant connect,resource to tranp;
--在該資料表空間建立表,用於測試
SQL> create table tranp.t01 as select * from sys.dba_objects;
1、檢查源、目標平台Endianness
在來源資料庫平台上:
SQL> SELECT d.PLATFORM_NAME, ENDIAN_FORMAT
2 FROM V$TRANSPORTABLE_PLATFORM. tp, V$DATABASE d
3 WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_NAME ENDIAN_FORMAT
------------------------------------ --------------
Microsoft Windows IA (32-bit) Little
在目標資料庫平台上:
SQL> SELECT d.PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM. tp, V$DATABASE d
WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_NAME ENDIAN_FORMAT
------------------------------------ --------------
Linux IA (32-bit) Little
由於源和目標平台的Endianness一致,可以省去convert這一步。
2、檢查要資料表空間是否自包含
SQL> EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('TBS_SINGLE',true);
PL/SQL 過程已成功完成。
SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;
未選定行
說明資料表空間是自包含的。
3、產生傳輸資料表空間集
建立目錄對象
SQL> create DIRECTORY tranp_dir as 'c:\software';
目錄已建立。
SQL> grant read,write on DIRECTORY tranp_dir to public;
授權成功。
將資料表空間置為唯讀。
SQL> alter tablespace tbs_single read only;
資料表空間已更改。
使用資料泵匯出傳輸資料表空間的中繼資料
註:如果Endianness不一致,還需要使用RMAN進行轉換資料表空間的資料檔案。
4、傳送資料表空間集
將資料表空間的資料檔案和匯出的DMP檔案,傳送到目標資料庫平台上。
5、匯入資料表空間
在目標資料庫中,建立相應的目錄對象和使用者。
SQL> create directory tranp_dir as '/home/oracle';
Directory created.
SQL> grant read,write on directory tranp_dir to public;
Grant succeeded.
SQL> create user tranp identified by oracle;
User created.
SQL> grant connect,resource to tranp;
Grant succeeded.
使用資料庫泵,匯入到目標資料庫中。
[oracle@ocmu ~]$ impdp system/oracle dumpfile=TBSINGLE.DMP directory=tranp_dir transport_datafiles=/u01/app/oracle/oradata/PROD/TBS_SINGLE01.DBF remap_schema=tranp:tranp
Import: Release 10.2.0.1.0 - Production on Thursday, 30 August, 2012 23:40:25
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** dumpfile=TBSINGLE.DMP directory=tranp_dir transport_datafiles=/u01/app/oracle/oradata/PROD/TBS_SINGLE01.DBF remap_schema=tranp:tranp
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 23:40:29
將被匯入的資料表空間置為read write。
SQL> alter tablespace TBS_SINGLE read write;
Tablespace altered.