利用imp/impdp传输表空间transport_tablespace满足以下条件
1.字符集相同
2.要导出的表空间必须是read only,而且是自包含的,就是说该表空间的对象不能依赖其他表空间。
3.先导出源数据,传输表空间的数据文件拷贝到另一个数据库相应目录下。
而RMAN不需要表空间READ ONLY,因为它是备份集进行传输,但是也需要字符集相同和自包含。
下面基于RMAN传输表空间的测试。
测试环境
源数据库:
OS=RHEL 6.4;
DB=Oracle11GR2 ;
IP=192.168.1.171;
SID=hjj;
ASM存储。
目标数据库:
OS=WIN7 64BIT;
DB=ORACLE11GR2;
IP=192.168.1.1;
SID=orcl;
FS存储。
一、在源数据库端
1.创建测试表空间
SQL> create tablespace tt1 datafile '+DATA_DG/hjj/datafile/test01.dbf' size 100m;
Tablespace created.
2.创建用户并授权
SQL> create user tt1 identified by oracle default tablespace tt1;
User created.
SQL> grant connect,resource to tt1;
Grant succeeded.
3.创建测试表
SQL> create table tt1.t as select * from dba_objects;
Table created.
4.查看数据
SQL> conn tt1/oracle
Connected.
SQL> select count(*) from t;
COUNT(*)
----------
21293
4.确认传输表空间的平台是否兼容
在源数据库端:
SQL> select tp.* from v$transportable_platform tp,v$database d where tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- -------------------------------------------------- --------------
10 Linux IA (32-bit) Little
在目标数据库端:
SQL> select tp.* from v$transportable_platform tp,v$database d where tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- -------------------------------------------------- ----------------------------
12 Microsoft Windows x86 64-bit Little
可以看到windows平台和linux都是Little,是兼容的。
5.确认源数据库的表空间是否自包含
SQL> exec dbms_tts.transport_set_check('tt1',true,true);
PL/SQL procedure successfully completed.
SQL> select * from transport_set_violations;
no rows selected
6.备份源数据库
[oracle@myrac1 ~]$ rman target sys/oracle@hjj catalog rman/rman
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Mar 5 19:54:06 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HJJ (DBID=2845675742)
connected to recovery catalog database
RMAN> sql "alter system checkpoint";
starting full resync of recovery catalog
full resync complete
sql statement: alter system checkpoint
RMAN> sql "alter system archive log current";
sql statement: alter system archive log current
RMAN> sql "alter system switch logfile";
sql statement: alter system switch logfile
RMAN> backup database;
Starting backup at 05-MAR-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA_DG/hjj/datafile/system.260.837919351
input datafile file number=00002 name=+DATA_DG/hjj/datafile/sysaux.261.837919391
input datafile file number=00005 name=+DATA_DG/hjj/datafile/tbs01.dbf
input datafile file number=00003 name=+DATA_DG/hjj/datafile/undotbs1.262.837919417
input datafile file number=00007 name=+DATA_DG/hjj/datafile/tt01.dbf
input datafile file number=00006 name=+DATA_DG/hjj/datafile/rman_tbs0.dbf
input datafile file number=00004 name=+DATA_DG/hjj/datafile/users.264.837919457
channel ORA_DISK_1: starting piece 1 at 05-MAR-14
channel ORA_DISK_1: finished piece 1 at 05-MAR-14
piece handle=+DG_FRA/hjj/backupset/2014_03_05/nnndf0_tag20140305t215129_0.265.841441893 tag=TAG20140305T215129 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 05-MAR-14
Starting Control File and SPFILE Autobackup at 05-MAR-14
piece handle=+DG_FRA/hjj/autobackup/2014_03_05/s_841441968.267.841441969 comment=NONE
Finished Control File and SPFILE Autobackup at 05-MAR-14
RMAN> backup archivelog all;