曾写过单个表空间传输的文章,参见:http://chinadm123.blog.51cto.com/3952657/1292737
在源端:
SQL> create tablespace test1 datafile 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test1.dbf' size 10M autoextend on;
表空间已创建。
SQL> create tablespace test2 datafile 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test2.dbf' size 10M autoextend on;
表空间已创建。
SQL> create user test1 identified by test1 default tablespace test1;
用户已创建。
SQL> create user test2 identified by test2 default tablespace test2;
用户已创建。
SQL> grant connect,resource,dba to test1,test2;
授权成功。
SQL> conn test1/test1
已连接。
SQL> create table t1 as select rownum id ,username from dba_users;
表已创建。
SQL> create index ind_t1 on t1(id) tablespace test2;
索引已创建。
SQL> commit;
提交完成。
SQL> conn test2/test2
已连接。
SQL> create table t2 as select rownum id,username from dba_users;
表已创建。
SQL> create index ind_t2 on t2(id) tablespace test1;
索引已创建。
SQL> commit;
提交完成。
SQL> select owner,segment_name,segment_type,tablespace_name from dba_segments where owner='TEST2';
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
------------------------------ -------------------- ------------------ -----------------------------
TEST2 T2 TABLE TEST2
TEST2 IND_T2 INDEX TEST1
SQL> select owner,segment_name,segment_type,tablespace_name from dba_segments where owner='TEST1';
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
------------------------------ -------------------- ------------------ -----------------------------
TEST1 T1 TABLE TEST1
TEST1 IND_T1 INDEX TEST2
SQL> conn /as sysdba
已连接。
SQL> exec dbms_tts.transport_set_check('TEST1',TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
VIOLATIONS
--------------------------------------------------------------------------------------------------
Index TEST2.IND_T2 in tablespace TEST1 points to table TEST2.T2 in tablespace TEST2
SQL> exec dbms_tts.transport_set_check('TEST1',TRUE,TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
VIOLATIONS
--------------------------------------------------------------------------------------------------
Index TEST1.IND_T1 in tablespace TEST2 points to table TEST1.T1 in tablespace TEST1
Index TEST2.IND_T2 in tablespace TEST1 points to table TEST2.T2 in tablespace TEST2
SQL> exec dbms_tts.transport_set_check('TEST2',TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
VIOLATIONS
--------------------------------------------------------------------------------------------------
Index TEST1.IND_T1 in tablespace TEST2 points to table TEST1.T1 in tablespace TEST1
SQL> exec dbms_tts.transport_set_check('TEST2',TRUE,TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
VIOLATIONS
--------------------------------------------------------------------------------------------------
Index TEST1.IND_T1 in tablespace TEST2 points to table TEST1.T1 in tablespace TEST1
Index TEST2.IND_T2 in tablespace TEST1 points to table TEST2.T2 in tablespace TEST2
SQL> exec dbms_tts.transport_set_check('TEST1,TEST2',TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
未选定行
SQL> exec dbms_tts.transport_set_check('TEST1,TEST2',TRUE,TRUE);
PL/SQL 过程已成功完成。
SQL> select * from transport_set_violations;
未选定行
SQL>
###############alter tablespace read only
SQL> alter tablespace test1 read only;
表空间已更改。
SQL> alter tablespace test2 read only;
表空间已更改。
###############expdp tablespace's metadata
expdp system/oracle directory=mydump dumpfile=expdp_test1test2.dmp logfile=expdp_test1test2.log transport_tablespaces=TEST1,TEST2
在目标端:
SQL> create user test1 identified by test1;
User created.
SQL> create user test2 identified by test2;
User created.
SQL> grant connect,resource,dba to test1;
Grant succeeded.
SQL> grant connect,resource,dba to test2;
Grant succeeded.
[oracle@node1 mydump]$ impdp system/oracle directory=dmp dumpfile=EXPDP_TEST1TEST2.DMP logfile=EXPDP_TEST1TEST2.log transport_datafiles=/test/mydump/TEST1.DBF,/test/mydump/TEST2.DBF
Import: Release 10.2.0.1.0 - 64bit Production on Monday, 09 September, 2013 14:51:12
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit 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/******** directory=dmp dumpfile=EXPDP_TEST1TEST2.DMP logfile=EXPDP_TEST1TEST2.log transport_datafiles=/test/mydump/TEST1.DBF,/test/mydump/TEST2.DBF
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 14:52:04
SQL> select tablespace_name,status from dba_tablespaces where tablespace_name in ('TEST1','TEST2');
TABLESPACE_NAME STATUS
------------------------------ ---------
TEST1 READ ONLY
TEST2 READ ONLY
SQL> ALTER user test1 default tablespace test1;
User altered.
SQL> ALTER user test2 default tablespace test2;
User altered.
SQL> conn test1/test1
Connected.
SQL> select count(*) from t1;
COUNT(*)
----------
25