3. 将 TBSASMMIG 移植到ASM 存储中。完成操作后,请检查移植是否成功,并且该表空间中的表是否保持原样。
sys@TEST0924> select FILE_NAME,TABLESPACE_NAME from dba_data_files; FILE_NAME TABLESPACE_NAME -------------------------------------------------- ------------------------------ /u01/app/oracle/oradata/test0924/users01.dbf USERS /u01/app/oracle/oradata/test0924/sysaux01.dbf SYSAUX /u01/app/oracle/oradata/test0924/system01.dbf SYSTEM /u01/app/oracle/oradata/test0924/example01.dbf EXAMPLE /u01/app/oracle/oradata/test0924/undotbs01.dbf UNDOTBS1 sys@TEST0924> create tablespace TBSASMMIG datafile '/u01/app/oracle/oradata/test0924/tbsasmmig01.dbf' size 10m; Tablespace created. sys@TEST0924> create table t2 (id number,name varchar2(20)) tablespace TBSASMMIG; Table created. sys@TEST0924> insert into t2 values (1,'a1'); 1 row created. sys@TEST0924> commit; Commit complete. sys@TEST0924> select file_id,file_name,tablespace_name from dba_data_files; FILE_ID FILE_NAME TABLESPACE_NAME ---------- -------------------------------------------------- ------------------------------ 4 /u01/app/oracle/oradata/test0924/users01.dbf USERS 3 /u01/app/oracle/oradata/test0924/tbsasmmig01.dbf TBSASMMIG 2 /u01/app/oracle/oradata/test0924/sysaux01.dbf SYSAUX 1 /u01/app/oracle/oradata/test0924/system01.dbf SYSTEM 5 /u01/app/oracle/oradata/test0924/example01.dbf EXAMPLE 9 /u01/app/oracle/oradata/test0924/undotbs01.dbf UNDOTBS1 6 rows selected. [oracle@rtest ~]$ rman target / Recovery Manager: Release 11.2.0.3.0 - Production on Sun Nov 3 17:02:51 2013 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: TEST0924 (DBID=2720875862) RMAN> sql 'alter database datafile 3 offline'; sql statement: alter database datafile 3 offline RMAN> backup as copy datafile 3 format '+DATA'; Starting backup at 03-NOV-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=127 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=191 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=157 device type=DISK channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/u01/app/oracle/oradata/test0924/tbsasmmig01.dbf output file name=+DATA/test0924/datafile/tbsasmmig.264.830538365 tag=TAG20131103T170603 RECID=13 STAMP=830538366 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 Finished backup at 03-NOV-13 Starting Control File and SPFILE Autobackup at 03-NOV-13 piece handle=/u01/app/oracle/fast_recovery_area/TEST0924/autobackup/2013_11_03/o1_mf_s_830538370_97fl6mr9_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 03-NOV-13 RMAN> switch datafile 3 to copy; datafile 3 switched to datafile copy "+DATA/test0924/datafile/tbsasmmig.264.830538365" RMAN> recover datafile 3; Starting recover at 03-NOV-13 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 03-NOV-13 RMAN> sql 'alter database datafile 3 online'; sql statement: alter database datafile 3 online sys@TEST0924> select file_id,file_name,tablespace_name from dba_data_files; FILE_ID FILE_NAME TABLESPACE_NAME ---------- -------------------------------------------------- ------------------------------ 4 /u01/app/oracle/oradata/test0924/users01.dbf USERS 3 +DATA/test0924/datafile/tbsasmmig.264.830538365 TBSASMMIG 2 /u01/app/oracle/oradata/test0924/sysaux01.dbf SYSAUX 1 /u01/app/oracle/oradata/test0924/system01.dbf SYSTEM 5 /u01/app/oracle/oradata/test0924/example01.dbf EXAMPLE 9 /u01/app/oracle/oradata/test0924/undotbs01.dbf UNDOTBS1 6 rows selected. sys@TEST0924> select * from t2 2 ; ID NAME ---------- -------------------- 1 a1
另一种转换方法:
RMAN> backup tablespace users; Starting backup at 24-OCT-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=163 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=226 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=9 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/u01/app/oracle/oradata/test0924/users01.dbf channel ORA_DISK_1: starting piece 1 at 24-OCT-13 channel ORA_DISK_1: finished piece 1 at 24-OCT-13 piece handle=/u01/app/oracle/fast_recovery_area/TEST0924/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T101748_96lc0dxh_.bkp tag=TAG20131024T101748 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 24-OCT-13 Starting Control File and SPFILE Autobackup at 24-OCT-13 piece handle=/u01/app/oracle/fast_recovery_area/TEST0924/autobackup/2013_10_24/o1_mf_s_829649875_96lc0obm_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 24-OCT-13 RMAN> run 2> {sql 'alter tablespace users offline immediate'; 3> set newname for datafile 4 to '+DATA'; 4> restore tablespace users; 5> switch datafile 4; 6> recover tablespace users; 7> sql 'alter tablespace users online'; 8> } sql statement: alter tablespace users offline immediate executing command: SET NEWNAME Starting restore at 24-OCT-13 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00004 to +DATA channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TEST0924/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T101748_96lc0dxh_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TEST0924/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T101748_96lc0dxh_.bkp tag=TAG20131024T101748 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 24-OCT-13 datafile 4 switched to datafile copy input datafile copy RECID=6 STAMP=829650049 file name=+DATA/test0924/datafile/users.260.829650045 Starting recover at 24-OCT-13 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 24-OCT-13 sql statement: alter tablespace users online sys@TEST0924> select file_name from dba_data_files; FILE_NAME ---------------------------------------------------------------------------------------------------- +DATA/test0924/datafile/users.260.829650045 /u01/app/oracle/oradata/test0924/sysaux01.dbf /u01/app/oracle/oradata/test0924/system01.dbf /u01/app/oracle/oradata/test0924/example01.dbf /u01/app/oracle/oradata/test0924/undotbs02.dbf /u01/app/oracle/oradata/test0924/undotbs01.dbf /u01/app/oracle/oradata/test0924/inventory01.dbf 7 rows selected.