Skip to content

Posts from the ‘Backup & Recovery’ Category

RMAN Recover database noredo commands

When our db running in noarchivelog mode, Online redolog file may failure occur during startup your db, how do you recover if you have a consistent cold backup avilable for your db ( No ArchiveLog Mode).

”  We can perform limited recovery of changes to a database running in NOARCHIVELOG mode by applying incremental backups. The incremental backups must be consistent, like all backups of a database run in NOARCHIVELOG mode, so you cannot back up the database when it is open.

Assume that you run database prod in NOARCHIVELOG mode with a recovery catalog. You shut down the database consistently and make a level 0 backup of database prod to tape on Sunday afternoon. You shut down the database consistently and make a level 1 differential incremental backup to tape at 3:00 a.m. on Wednesday and Friday.

On Saturday, a media failure destroys half of the datafiles as well as the online redo logs. Because the online logs are lost, you must specify the NOREDO option in the RECOVER command. Otherwise, RMAN searches for the redo logs after applying the Friday incremental backup and issues an error message when it does not find them. ”

Just a Example :

Step 1: Create user and table


Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create tablespace testfor datafile 'c:\oracle\testfor01.dbf' size 50m;

Tablespace created.

SQL> create user testme identified by testme default tablespace testfor;

User created.

SQL> grant connect,resource to testme;

Grant succeeded.

SQL> conn testme/testme;
Connected.
SQL> create table test(emp varchar2(20));

Table created.

SQL> insert into test values('azar');

1 row created.

SQL> commit;

Commit complete.

Step 2 : Shutdown and Startup mount


SQL> conn / as sysdba
Connected.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.

Step 3: I took RMAN Backup

SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Feb 13 12:52:14 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TESTDB (DBID=2526327566, not open)
RMAN> backup incremental level 0 database;

Starting backup at 13-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.D
BF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.D
BF
input datafile fno=00005 name=C:\ORACLE\TESTFOR01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\UNDOTBS01.
DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 13-FEB-11
channel ORA_DISK_1: finished piece 1 at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.BKP tag=TAG20110213T125556 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 13-FEB-11

Starting Control File and SPFILE Autobackup at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011
_02_13\O1_MF_S_742999909_6OHBPTCT_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 13-FEB-11

RMAN> exit
Recovery Manager complete.

Step 4: I just added more rows for test table.

C:\Documents and Settings\Administrator>exit

SQL> alter database open;

Database altered.

SQL> conn testme/testme;
Connected.
SQL> insert into test values('kareem');

1 row created.

SQL> insert into test values('idrees');

1 row created.

SQL> insert into test values('jabar');

1 row created.

SQL> commit;

Commit complete.

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.
SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Step 5:  Now I just took Incremantal backup

C:\Documents and Settings\Administrator>rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Feb 13 12:59:41 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TESTDB (DBID=2526327566, not open)

RMAN> backup incremental level 1 database;

Starting backup at 13-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.D
BF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.D
BF
input datafile fno=00005 name=C:\ORACLE\TESTFOR01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\UNDOTBS01.
DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 13-FEB-11
channel ORA_DISK_1: finished piece 1 at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.BKP tag=TAG20110213T125954 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 13-FEB-11

Starting Control File and SPFILE Autobackup at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011
_02_13\O1_MF_S_743000354_6OHBXFQT_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 13-FEB-11

RMAN>

Step 6: Again I just added one row for TEST table


SQL> alter database open;

Database altered.

SQL> conn testme/testme;
Connected.
SQL> insert into test values('norecover');

1 row created.

SQL> commit;

Commit complete.

Step 7: Log group status


SQL> conn / as sysdba
Connected.
SQL> select group#,status,thread#,sequence#,first_change# from v$log;

    GROUP# STATUS              THREAD#  SEQUENCE# FIRST_CHANGE#
---------- ---------------- ---------- ---------- -------------
         1 CURRENT                   1          2        545486
         2 UNUSED                    1          0             0
         3 INACTIVE                  1          1        534907

Step 8: I just moved logile to another location


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down. 

C:\oracle\product\10.2.0\oradata\testdb>move redo01.log c:\oracle\

SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1:
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\REDO01.LOG'

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

Step 9: Now Time to recover using recover database NOREDO command.


RMAN> startup nomount

connected to target database (not started)
Oracle instance started

Total System Global Area     167772160 bytes

Fixed Size                     1247900 bytes
Variable Size                 75498852 bytes
Database Buffers              88080384 bytes
Redo Buffers                   2945024 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 13-FEB-11
using channel ORA_DISK_1

recovery area destination: C:\oracle\product\10.2.0/flash_recovery_area
database name (or database unique name) used for search: TESTDB
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AR
EA\TESTDB\AUTOBACKUP\2011_02_13\O1_MF_S_743000354_6OHBXFQT_.BKP
channel ORA_DISK_1: control file restore from autobackup complete
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL01.CTL
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL02.CTL
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL03.CTL
Finished restore at 13-FEB-11

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 13-FEB-11
Starting implicit crosscheck backup at 13-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 13-FEB-11

Starting implicit crosscheck copy at 13-FEB-11
using channel ORA_DISK_1
Finished implicit crosscheck copy at 13-FEB-11

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011_0
2_13\O1_MF_S_743000354_6OHBXFQT_.BKP

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.DBF

restoring datafile 00002 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\UNDOTBS01.DB
F
restoring datafile 00003 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.DBF

restoring datafile 00004 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DBF
restoring datafile 00005 to C:\ORACLE\TESTFOR01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\TESTDB\BACKUPSET\2011_02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.BKP tag=TAG20110213T125556
channel ORA_DISK_1: restore complete, elapsed time: 00:01:16
Finished restore at 13-FEB-11

RMAN> recover database;

Starting recover at 13-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\SYSTEM01.DBF
destination for restore of datafile 00002: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\UNDOTBS01.DBF
destination for restore of datafile 00003: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\SYSAUX01.DBF
destination for restore of datafile 00004: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\USERS01.DBF
destination for restore of datafile 00005: C:\ORACLE\TESTFOR01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\TESTDB\BACKUPSET\2011_02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.BKP tag=TAG20110213T125954
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

starting media recovery

unable to find archive log
archive log thread=1 sequence=2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/13/2011 14:51:58
RMAN-06054: media recovery requesting unknown log: thread 1 seq 2 lowscn 547146

RMAN> recover database noredo;

Starting recover at 13-FEB-11
using channel ORA_DISK_1
Finished recover at 13-FEB-11

RMAN> alter database open resetlogs;

database opened

RMAN>

Now database Opened, I’m going to check Wheter my last added row avilable  (Step 6) or not because It added after taken incremental backup.


SQL> conn testme/testme;
Connected.
SQL> select * from test;

EMP
--------------------
azar
kareem
idrees
jabar

SQL>

Now There is no last added row avilable, because ” The recovered database reflects only changes up through the time of the Friday incremental backup. Because there are no archived redo logs, there is no way to recover changes made after the incremental backup ”

Ref :-

http://www.comp.dit.ie/btierney/oracle11gdoc/backup.111/b28273/rcmsynta030.htm#CHDHFBFI

Recover missing datafile using RMAN Data Recoveray advisor

This is one Oracle 11g New feature. Here I’m go to show How to recover missing datafile using RMAN data recovery advisor without taking previous backup.

SQL> create tablespace datarec datafile 'd:\backupnew\datarec01.dbf' size 50m;

Tablespace created.

SQL> create user datarec identified by datarec default tablespace datarec;

User created.

SQL> grant connect,resource to datarec;

Grant succeeded.

SQL> conn datarec/datarec;
Connected.
SQL> create table test(empno number,name varchar2(20));

Table created.

SQL> insert into test values(001,'azar');

1 row created.

SQL> insert into test values(002,'kareem');

1 row created.

SQL> commit;

Commit complete.
SQL> conn datarec/datarec;
Connected.
SQL> select * from test;

     EMPNO NAME
---------- --------------------
         1 azar
         2 kareem

SQL>

Shutdown Database

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

Delete particular DBF file using OS command manualy.

d:\backupnew>dir
Volume in drive D has no label.
Volume Serial Number is 3861-730C

Directory of d:\backupnew

08-Jan-11 11:35 AM .
08-Jan-11 11:35 AM ..
08-Jan-11 11:33 AM 2,002,329,600 ACE01.DBF
08-Jan-11 10:13 AM 130,838 archive.txt
08-Jan-11 10:12 AM 148,590 archivelog.txt
01-Jan-11 04:50 PM AZARDB
08-Jan-11 11:35 AM 52,436,992 DATAREC01.DBF
03-Jan-11 10:06 AM 1,116 initazar.ora
03-Jan-11 10:19 AM 1,115 initazardb.ora
03-Jan-11 09:11 AM New folder
03-Jan-11 09:16 AM 104,865,792 TESTTBS01.DBF
01-Jan-11 05:12 PM 86,016 TSPITR_EINS_53941.DMP
01-Jan-11 05:57 PM 86,016 TSPITR_LBFD_89576.DMP
9 File(s) 2,160,086,075 bytes
4 Dir(s) 106,103,545,856 bytes free

d:\backupnew>del datarec01.dbf

Startup database

SQL> startup
ORACLE instance started.

Total System Global Area 535662592 bytes
Fixed Size 1375792 bytes
Variable Size 335544784 bytes
Database Buffers 192937984 bytes
Redo Buffers 5804032 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 15 - see DBWR trace file
ORA-01110: data file 15: 'D:\BACKUPNEW\DATAREC01.DBF'

Recover missing datafile using RMAN Data Recovery Advisor

C:\Users\mazar>set oracle_sid=azardb

C:\Users\mazar>rman target sys/Admin123

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 8 11:40:07 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: AZARDB (DBID=1652383192, not open)

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
67468 HIGH OPEN 08-JAN-11 One or more non-system datafiles are missing

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
67468 HIGH OPEN 08-JAN-11 One or more non-system datafiles are missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file D:\BACKUPNEW\DATAREC01.DBF was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 15
Strategy: The repair includes complete media recovery with no data loss
Repair script: c:\app\oracle\mazar\diag\rdbms\azardb\azardb\hm\reco_3190867713.hm

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: c:\app\oracle\mazar\diag\rdbms\azardb\azardb\hm\reco_3190867713.hm

contents of repair script:
# restore and recover datafile
restore datafile 15;
recover datafile 15;

Do you really want to execute the above repair (enter YES or NO)? y
executing repair script

Starting restore at 08-JAN-11
using channel ORA_DISK_1

creating datafile file number=15 name=D:\BACKUPNEW\DATAREC01.DBF
restore not done; all files read only, offline, or already restored
Finished restore at 08-JAN-11

Starting recover at 08-JAN-11
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 08-JAN-11
repair failure complete
RMAN>SQL> alter database open;

Database altered.

SQL> select name,status from v$datafile where file#=15;

NAME
--------------------------------------------------------------------------------
STATUS
-------
D:\BACKUPNEW\DATAREC01.DBF
ONLINE

SQL>SQL> conn datarec/datarec;
Connected.
SQL> select * from test;

EMPNO NAME
---------- --------------------
1 azar
2 kareem

SQL>

Controfile Recover :

And also Checking For Control File. I just moved controlfile and startup database ,It shows error,
then i just recovered Controlfile using RMAN data Recovery Advisor.

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL
C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\CONTROL02.CTL

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
C:\app\oracle\mazar\oradata\azardb>move control01.ctl C:\APP\ORACLE\MAZAR\ORADATA\
        1 file(s) moved. 
SQL> startup
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             335544784 bytes
Database Buffers          192937984 bytes
Redo Buffers                5804032 bytes
ORA-00205: error in identifying control file, check alert log for more info

 

RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
75867      CRITICAL OPEN      08-JAN-11     Control file C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL is missing

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
75867      CRITICAL OPEN      08-JAN-11     Control file C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL is missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=9 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
no manual actions available

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Use a multiplexed copy to restore control file C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: c:\app\oracle\mazar\diag\rdbms\azardb\azardb\hm\reco_2373618729.hm

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: c:\app\oracle\mazar\diag\rdbms\azardb\azardb\hm\reco_2373618729.hm

contents of repair script:
   # restore control file using multiplexed copy
   restore controlfile from 'C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\CONTROL02.CTL';
   sql 'alter database mount';

Do you really want to execute the above repair (enter YES or NO)? y
executing repair script

Starting restore at 08-JAN-11
using channel ORA_DISK_1

channel ORA_DISK_1: copied control file copy
output file name=C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL
output file name=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\CONTROL02.CTL
Finished restore at 08-JAN-11

sql statement: alter database mount
released channel: ORA_DISK_1
repair failure complete

RMAN>
SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> alter database open;

Database altered.

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL
C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\CONTROL02.CTL

SQL>
Just for My understanding
http://forums.oracle.com/forums/thread.jspa?threadID=2155786&tstart=0

How to recover datafile not backed up

Recently i just added one datafile for a tablespace and later, had a media failure occur before I backuped recently datafile.In this case , How do we recover.

We have previous Good Database backup.

Redo files needed upto Datafiles created.

If you have a current control file, we can restore , recover datafile & tablespace or database level.

Now See Below Example :

before I just backuped database with archivelogs.

Now I’m go to Add datafile to a existing tablespace.

SQL> alter tablespace testtbs add datafile 'D:\BACKUP\RESTORENEW\TESTTBS02.dbf' SIZE 50M;

Tablespace altered. 

SQL> select file_name from dba_data_files where tablespace_name='TESTTBS';

FILE_NAME
--------------------------------------------------------------------------------
D:\BACKUP\RESTORENEW\TESTTBS01.DBF
D:\BACKUP\RESTORENEW\TESTTBS02.DBF

Now I moved Recently added DBF file to other location

d:\backup\restorenew>move testtbs02.dbf d:\backup
        1 file(s) moved.

d:\backup\restorenew>

Shutdown Database & Startup

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             331350480 bytes
Database Buffers          197132288 bytes
Redo Buffers                5804032 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 12 - see DBWR trace file
ORA-01110: data file 12: 'D:\BACKUP\RESTORENEW\TESTTBS02.DBF'

Now Recover tablespace using RMAN

RMAN> restore tablespace testtbs;

Starting restore at 03-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

creating datafile file number=12 name=D:\BACKUP\RESTORENEW\TESTTBS02.DBF
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 00009 to D:\BACKUP\RESTORENEW\TESTTBS01.DBF
channel ORA_DISK_1: reading from backup piece C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T122037_6L357C6K_.BKP
channel ORA_DISK_1: piece handle=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T122037_6L357C6K_.BKP tag=TAG201101
03T122037
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 03-JAN-11

RMAN> recover tablespace testtbs;

Starting recover at 03-JAN-11
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 03-JAN-11

RMAN> alter database open;

database opened

Let me check datafile

SQL> select file_name from dba_data_files where tablespace_name='TESTTBS';

FILE_NAME
--------------------------------------------------------------------------------
D:\BACKUP\RESTORENEW\TESTTBS01.DBF
D:\BACKUP\RESTORENEW\TESTTBS02.DBF

Using A backup Control file

If we’re using a backup control file that has no information about the datafile, then we must restore and recover at the database level.

I just added another datafile also.

SQL> alter tablespace testtbs add datafile 'D:\BACKUP\RESTORENEW\TESTTBS03.dbf' SIZE 50M;

Tablespace altered.

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area     535662592 bytes

Fixed Size                     1375792 bytes
Variable Size                331350480 bytes
Database Buffers             197132288 bytes
Redo Buffers                   5804032 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 03-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK

recovery area destination: C:\app\oracle\mazar\flash_recovery_area
database name (or database unique name) used for search: AZARDB
channel ORA_DISK_1: AUTOBACKUP C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2011_01_03\O1_MF_S_739455960_6L35KBTC_.BKP found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20110103
channel ORA_DISK_1: restoring control file from AUTOBACKUP C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2011_01_03\O1_MF_S_739455960_6L35KBTC_.BKP

channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\CONTROL01.CTL
output file name=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\CONTROL02.CTL
Finished restore at 03-JAN-11

RMAN> alter database mount;

database mounted

RMAN> restore database;

Starting restore at 03-JAN-11
Starting implicit crosscheck backup at 03-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 03-JAN-11

Starting implicit crosscheck copy at 03-JAN-11
using channel ORA_DISK_1
Crosschecked 17 objects
Finished implicit crosscheck copy at 03-JAN-11

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_03\O1_MF_1_29_6L2X3V22_.ARC
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_03\O1_MF_1_29_6L2XL3M4_.ARC
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2010_12_26\O1_MF_S_738773797_6KGCCPPK_.BKP
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2010_12_26\O1_MF_S_738777392_6KGGW2R7_.BKP
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2010_12_27\O1_MF_N_738851503_6KJQ80HG_.BKP
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2010_12_27\O1_MF_N_738851640_6KJY64RH_.BKP
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2010_12_27\O1_MF_S_738813797_6KHLFP6B_.BKP
File Name: C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2011_01_03\O1_MF_S_739455960_6L35KBTC_.BKP

using channel ORA_DISK_1

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 00001 to C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to D:\BACKUP\ADDME01.DBF
channel ORA_DISK_1: restoring datafile 00004 to C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\USERS01.DBF
channel ORA_DISK_1: restoring datafile 00005 to C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\EXAMPLE01.DBF
channel ORA_DISK_1: restoring datafile 00006 to D:\BACKUP\RCRMAN01.DBF
channel ORA_DISK_1: restoring datafile 00007 to D:\BACKUP\USERSTBS01.DBF
channel ORA_DISK_1: restoring datafile 00008 to D:\BACKUP\UNDOTBS02.DBF
channel ORA_DISK_1: restoring datafile 00009 to D:\BACKUP\RESTORENEW\TESTTBS01.DBF
channel ORA_DISK_1: restoring datafile 00010 to D:\BACKUP\TESTDB001.DBF
channel ORA_DISK_1: restoring datafile 00011 to D:\BACKUP\TESTTB1.DBF
channel ORA_DISK_1: reading from backup piece C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T122037_6L357C6K_.BKP
channel ORA_DISK_1: piece handle=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T122037_6L357C6K_.BKP tag=TAG201101
03T122037
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:05
Finished restore at 03-JAN-11

RMAN> recover database;

Starting recover at 03-JAN-11
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 34 is already on disk as file C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_03\O1_MF_1_34_6L35K2PO_
.ARC
archived log for thread 1 with sequence 35 is already on disk as file C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\REDO03.LOG
archived log file name=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_03\O1_MF_1_34_6L35K2PO_.ARC thread=1 sequence=34
archived log file name=C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\REDO03.LOG thread=1 sequence=35
creating datafile file number=12 name=D:\BACKUP\RESTORENEW\TESTTBS02.DBF
archived log file name=C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\REDO03.LOG thread=1 sequence=35
creating datafile file number=13 name=D:\BACKUP\RESTORENEW\TESTTBS03.DBF
archived log file name=C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\REDO03.LOG thread=1 sequence=35
media recovery complete, elapsed time: 00:00:06
Finished recover at 03-JAN-11

RMAN> alter database open resetlogs;

database opened
SQL> select file_name from dba_data_files where tablespace_name='TESTTBS';

FILE_NAME
--------------------------------------------------------------------------------
D:\BACKUP\RESTORENEW\TESTTBS02.DBF
D:\BACKUP\RESTORENEW\TESTTBS03.DBF
D:\BACKUP\RESTORENEW\TESTTBS01.DBF

Recover dropped tablespace using RMAN tablespace point in time recovery

This is new feature for Oracle 11g R2.Here I’m go to demonstrate How to recover dropped Tablespace using RMAN Tablespace point in time recovery.

Download PDF Document from here

Recover Dropped tablespace using RMAN TSPITR pdf

Right Click on this URL, Save Target as  & then Download it.

Step 1: Create Tablespace

SQL> conn / as sysdba

Connected.

SQL> create tablespace testtbs datafile 'd:\backup\testtbs01.dbf' size 100m; 

Tablespace created. 

SQL> create user testtbs identified by testtbs default tablespace testtbs; 

User created. 

SQL> grant connect,resource to testtbs; 

Grant succeeded. 

SQL> conn testtbs/testtbs;

Connected.

SQL> create table test(empname varchar2(20),city varchar2(20)); 

Table created.

SQL> insert into test values('azar','riyadh'); 

1 row created. 

SQL> insert into test values('jabar','chennai'); 

1 row created.

SQL> commit; 

Commit complete.

 SQL> conn testdb/testdb;

Connected. 

(Note : This table allocated for other tablespace , i just insert data for this table for check data consistent after doing TBPITR)

SQL> create table d(empname varchar2(20)); 

Table created. 

SQL> insert into d values('kareem'); 

1 row created. 

SQL> insert into d values('syed'); 

1 row created. 

SQL> commit; 

Commit complete.

Step 2:  Backup database Plus archivelog


C:\Users\mazar>set oracle_sid=azardb 

C:\Users\mazar>rman target sys/Admin123 

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 1 15:39:34 2011 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. 

connected to target database: AZARDB (DBID=1652383192) 

RMAN> backup database plus archivelog;

Starting backup at 01-JAN-11

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=30 device type=DISK

Step 3: Note Current SCN


SQL> conn / as sysdba

Connected.

SQL> select current_scn from v$database; 

CURRENT_SCN

-----------

    8448197

Step 4: Drop tablespace


SQL> drop tablespace testtbs including contents and datafiles; 

Tablespace dropped.

Step 5: I just added data for another table allocated for other tablespace due to  just check for data consistent.


SQL> conn testdb/testdb;

Connected.

SQL> insert into d values('azmi'); 

1 row created. 

SQL> commit; 

Commit complete.

Step 6: Create auxiliary & Recover tablespace using tablespace point in time recovery.

C:\Windows\system32>rman target sys/Admin123 

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 1 14:45:08 2011 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. 

connected to target database: AZARDB (DBID=1652383192)

 RMAN> run{

2> recover tablespace testtbs

3> until scn 8448197

4> auxiliary destination 'D:\backupnew'; 

5> } 

executing command: SET NEWNAME 

Starting recover at 01-JAN-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=31 device type=DISK

RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point-in-time 

List of tablespaces expected to have UNDO segments

Tablespace SYSTEM

Tablespace UNDOTBS2

Creating automatic instance, with SID='Bopd' 

initialization parameters used for automatic instance:

db_name=AZARDB

db_unique_name=Bopd_tspitr_AZARDB

compatible=11.2.0.0.0

db_block_size=8192

db_files=200

sga_target=280M

processes=50

db_create_file_dest=D:\backupnew

log_archive_dest_1='location=D:\backupnew'

#No auxiliary parameter file used

starting up automatic instance AZARDB

Oracle instance started

Total System Global Area     292933632 bytes 

Fixed Size                     1374164 bytes

Variable Size                100665388 bytes

Database Buffers             184549376 bytes

Redo Buffers                   6344704 bytes

Automatic instance created

List of tablespaces that have been dropped from the target database:

Tablespace testtbs

contents of Memory Script:

{

# set requested point in time

set until  scn 8448197;

# restore the controlfile

restore clone controlfile;

# mount the controlfile

sql clone 'alter database mount clone database';

# archive current online log

sql 'alter system archive log current';

# avoid unnecessary autobackups for structural changes during TSPITR

sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';

}

executing Memory Script

executing command: SET until clause

Starting restore at 01-JAN-11

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=59 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: reading from backup piece C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2011_01_01\O1_MF_N_739286122_6KXZOWTT_.BKP

channel ORA_AUX_DISK_1: piece handle=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\AUTOBACKUP\2011_01_01\O1_MF_N_739286122_6KXZOWTT_.BKP tag=TAG20110101T13152

1

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:00

output file name=D:\BACKUPNEW\AZARDB\CONTROLFILE\O1_MF_6KY50OH2_.CTL

Finished restore at 01-JAN-11

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

contents of Memory Script:

{

# set requested point in time

set until  scn 8448197;

# set destinations for recovery set and auxiliary set datafiles

set newname for clone datafile  1 to new;

set newname for clone datafile  8 to new;

set newname for clone datafile  2 to new;

set newname for clone tempfile  1 to new;

set newname for datafile  3 to

 "D:\BACKUP\TESTTBS01.DBF";

# switch all tempfiles

switch clone tempfile all;

# restore the tablespaces in the recovery set and the auxiliary set

restore clone datafile  1, 8, 2, 3;

switch clone datafile all;

}

executing Memory Script 

executing command: SET until clause 

executing command: SET NEWNAME 

executing command: SET NEWNAME 

executing command: SET NEWNAME 

executing command: SET NEWNAME 

executing command: SET NEWNAME 

renamed tempfile 1 to D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_TEMP_%U_.TMP in control file 

Starting restore at 01-JAN-11

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSTEM_%U_.DBF

channel ORA_AUX_DISK_1: restoring datafile 00008 to D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_UNDOTBS2_%U_.DBF

channel ORA_AUX_DISK_1: restoring datafile 00002 to D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSAUX_%U_.DBF

channel ORA_AUX_DISK_1: restoring datafile 00003 to D:\BACKUP\TESTTBS01.DBF

channel ORA_AUX_DISK_1: reading from backup piece C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_01\O1_MF_NNNDF_TAG20110101T131020_6KXZDFVB_.

BKP

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:03:06

Finished restore at 01-JAN-11

datafile 1 switched to datafile copy

input datafile copy RECID=388 STAMP=739291881 file name=D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSTEM_6KY53Y6C_.DBF

datafile 8 switched to datafile copy

input datafile copy RECID=389 STAMP=739291881 file name=D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_UNDOTBS2_6KY53YJT_.DBF

datafile 2 switched to datafile copy

input datafile copy RECID=390 STAMP=739291881 file name=D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSAUX_6KY53YG4_.DBF

contents of Memory Script:

{

# set requested point in time

set until  scn 8448197;

# online the datafiles restored or switched

sql clone "alter database datafile  1 online";

sql clone "alter database datafile  8 online";

sql clone "alter database datafile  2 online";

sql clone "alter database datafile  3 online";

# recover and open resetlogs

recover clone database tablespace  "TESTTBS", "SYSTEM", "UNDOTBS2", "SYSAUX" delete archivelog;

alter clone database open resetlogs;

}

executing Memory Script 

executing command: SET until clause 

sql statement: alter database datafile  1 online 

sql statement: alter database datafile  8 online 

sql statement: alter database datafile  2 online 

sql statement: alter database datafile  3 online 

Starting recover at 01-JAN-11

using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 17 is already on disk as file C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_01\O1_MF_1_17_6KY53B3J_

.ARC

channel ORA_AUX_DISK_1: starting archived log restore to default destination

channel ORA_AUX_DISK_1: restoring archived log

archived log thread=1 sequence=16

channel ORA_AUX_DISK_1: reading from backup piece C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_01\O1_MF_ANNNN_TAG20110101T131514_6KXZOPGN_.

BKP

channel ORA_AUX_DISK_1: piece handle=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\BACKUPSET\2011_01_01\O1_MF_ANNNN_TAG20110101T131514_6KXZOPGN_.BKP tag=TAG20

110101T131514

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=D:\BACKUPNEW\ARC0000000016_0738861267.0001 thread=1 sequence=16

channel clone_default: deleting archived log(s)

archived log file name=D:\BACKUPNEW\ARC0000000016_0738861267.0001 RECID=777 STAMP=739291886

archived log file name=C:\APP\ORACLE\MAZAR\FLASH_RECOVERY_AREA\AZARDB\ARCHIVELOG\2011_01_01\O1_MF_1_17_6KY53B3J_.ARC thread=1 sequence=17

media recovery complete, elapsed time: 00:00:06

Finished recover at 01-JAN-11

database opened

contents of Memory Script:

{

# make read only the tablespace that will be exported

sql clone 'alter tablespace  TESTTBS read only';

# create directory for datapump import

sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''

D:\backupnew''";

# create directory for datapump export

sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''

D:\backupnew''";

}

executing Memory Script

sql statement: alter tablespace  TESTTBS read only

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''D:\backupnew''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''D:\backupnew''

Performing export of metadata...

   EXPDP> Starting "SYS"."TSPITR_EXP_Bopd":

   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK

   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE

   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

   EXPDP> Master table "SYS"."TSPITR_EXP_Bopd" successfully loaded/unloaded

   EXPDP> ******************************************************************************

   EXPDP> Dump file set for SYS.TSPITR_EXP_Bopd is:

   EXPDP>   D:\BACKUPNEW\TSPITR_BOPD_37645.DMP

   EXPDP> ******************************************************************************

   EXPDP> Datafiles required for transportable tablespace TESTTBS:

   EXPDP>   D:\BACKUP\TESTTBS01.DBF

   EXPDP> Job "SYS"."TSPITR_EXP_Bopd" successfully completed at 15:12:24

Export completed

contents of Memory Script:

{

# shutdown clone before import

shutdown clone immediate

}

executing Memory Script

database closed

database dismounted

Oracle instance shut down

Performing import of metadata...

   IMPDP> Master table "SYS"."TSPITR_IMP_Bopd" successfully loaded/unloaded

   IMPDP> Starting "SYS"."TSPITR_IMP_Bopd":

   IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK

   IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE

   IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

   IMPDP> Job "SYS"."TSPITR_IMP_Bopd" successfully completed at 15:16:47

Import completed

contents of Memory Script:

{

# make read write and offline the imported tablespaces

sql 'alter tablespace  TESTTBS read write';

sql 'alter tablespace  TESTTBS offline';

# enable autobackups after TSPITR is finished

sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';

}

executing Memory Script 

sql statement: alter tablespace  TESTTBS read write 

sql statement: alter tablespace  TESTTBS offline 

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end; 

Removing automatic instance

Automatic instance removed

auxiliary instance file D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_TEMP_6KY5C761_.TMP deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\ONLINELOG\O1_MF_4_6KY5BT82_.LOG deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\ONLINELOG\O1_MF_3_6KY5BQSZ_.LOG deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\ONLINELOG\O1_MF_2_6KY5BOYS_.LOG deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\ONLINELOG\O1_MF_1_6KY5BMV3_.LOG deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSAUX_6KY53YG4_.DBF deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_UNDOTBS2_6KY53YJT_.DBF deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\DATAFILE\O1_MF_SYSTEM_6KY53Y6C_.DBF deleted

auxiliary instance file D:\BACKUPNEW\AZARDB\CONTROLFILE\O1_MF_6KY50OH2_.CTL deleted

Finished recover at 01-JAN-11

RMAN>

Step 7: Check tablespace status


SQL> select status,tablespace_name from dba_tablespaces where tablespace_name like 'TESTTBS%'; 

STATUS    TABLESPACE_NAME

--------- ------------------------------

OFFLINE   TESTTBS 

11 rows selected. 

Alter tablespace online

SQL> alter tablespace testtbs online; 

Tablespace altered.

Step 8: Check table

SQL> conn testtbs/testtbs;

Connected.

SQL> select * from tab; 

TNAME                          TABTYPE  CLUSTERID

------------------------------ ------- ----------

TEST                           TABLE 

SQL> select * from test; 

EMPNAME              CITY

-------------------- --------------------

azar                 riyadh

jabar                chennai

SQL> 

And also I'm go to check other table for data consistent. 

SQL> conn testdb/testdb;

Connected.

SQL> select * from d; 

EMPNAME

--------------------

azmi

kareem

syed

Now successfully recovered dropped tablespace using RMAN point in time recovery.

ORA-19852: error creating services for auxiliary instance

During Auxiliary instance creation , the following error appeared.

RMAN> run{
2> set newname for datafile 12 to ‘D:\backup\%f’;
3> recover tablespace testtbs
4> until scn 8448197
5> auxiliary destination ‘D:\backupnew’;
6> }

executing command: SET NEWNAME

Starting recover at 01-JAN-11
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point-in-time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS2

Creating automatic instance, with SID=’CBka’
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/01/2011 14:43:56
ORA-19852: error creating services for auxiliary instance CBka (error 0)
ORA-27302: failure occurred at:
ORA-27303: additional information: failed to start instance

 

You need to run following command in sql prompt.

SQL> exec dbms_backup_restore.manageauxinstance (‘TSPITR’,1);

PL/SQL procedure successfully completed.

Now you can try to re-exeucte , It should be work. 🙂

 

Duplicate database from ASM to non ASM

Download PDF Document from here


Duplicate Database from ASM to Non pdf

Right click on thir URL, Save Target as & then Download it.


Step 1:

Determine how much disk space will be required.

SQL> select name from v$database;

NAME
---------
AZARDB

Calculate total space for all datafiles within database

SQL> select DF.TOTAL/1048576 "DataFile Size Mb",LOG.TOTAL/1048576 "Redo Log Size Mb",CONTROL.TOTAL/1048576 "Control File Size Mb",
(DF.TOTAL + LOG.TOTAL + CONTROL.TOTAL)/1048576 "Total Size Mb" from dual,(select sum(a.bytes) TOTAL from dba_data_files a) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG,(select sum((cffsz+1)*cfbsz) TOTAL from x$kcccf c) CONTROL ;

DataFile Size Mb Redo Log Size Mb
---------------- ----------------
Control File Size Mb Total Size Mb
-------------------- -------------
1310              150
18.59375    1478.59375

Calculate space for list of datafiles within primary database

SQL> select DF.TOTAL/1048576 "DataFile Size Mb",
LOG.TOTAL/1048576 "Redo Log Size Mb",
CONTROL.TOTAL/1048576 "Control File Size Mb",
(DF.TOTAL + LOG.TOTAL + CONTROL.TOTAL)/1048576 "Total Size Mb" from dual,
(select sum(a.bytes) TOTAL from dba_data_files a where tablespace_name in ('SYSTEM','SYSAUX','UNDO','USERS')) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG,
(select sum((cffsz+1)*cfbsz) TOTAL from x$kcccf c) CONTROL ;

DataFile Size Mb Redo Log Size Mb
---------------- ----------------
Control File Size Mb Total Size Mb
-------------------- -------------
1165              150
18.59375    1333.59375

Step 2: backup Source database

RMAN> run{
2> allocate channel d1 type disk;
3> backup format '/backups/df_t%t_s%s_p%p' database;
4> sql 'alter system archive log current';
5> backup format '/backups/al_t%t_s%s_p%p' archivelog all;
6> release channel d1;
7> }

released channel: ORA_DISK_1
allocated channel: d1
channel d1: SID=44 device type=DISK

Starting backup at 17-DEC-10
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/azardb/datafile/system.256.736179685
input datafile file number=00002 name=+DATA/azardb/datafile/sysaux.257.736179685
input datafile file number=00005 name=+DATA/azardb/datafile/example.269.736179971
input datafile file number=00003 name=+DATA/azardb/datafile/undotbs1.258.736179685
input datafile file number=00004 name=+SPTEST/azardb/datafile/users.256.737964169
channel d1: starting piece 1 at 17-DEC-10
channel d1: finished piece 1 at 17-DEC-10
piece handle=/backups/df_t737969795_s6_p1 tag=TAG20101217T073635 comment=NONE
channel d1: backup set complete, elapsed time: 00:02:27
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 17-DEC-10
channel d1: finished piece 1 at 17-DEC-10
piece handle=/backups/df_t737969943_s7_p1 tag=TAG20101217T073635 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-DEC-10

sql statement: alter system archive log current

Starting backup at 17-DEC-10
current log archived
channel d1: starting archived log backup set
channel d1: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=1 STAMP=736268182
input archived log thread=1 sequence=4 RECID=2 STAMP=736345263
input archived log thread=1 sequence=5 RECID=3 STAMP=736438711
input archived log thread=1 sequence=6 RECID=4 STAMP=737551583
input archived log thread=1 sequence=7 RECID=5 STAMP=737880523
input archived log thread=1 sequence=8 RECID=6 STAMP=737897929
input archived log thread=1 sequence=9 RECID=7 STAMP=737962069
input archived log thread=1 sequence=10 RECID=8 STAMP=737969217
input archived log thread=1 sequence=11 RECID=9 STAMP=737969220
input archived log thread=1 sequence=12 RECID=10 STAMP=737969948
input archived log thread=1 sequence=13 RECID=11 STAMP=737969948
channel d1: starting piece 1 at 17-DEC-10
channel d1: finished piece 1 at 17-DEC-10
piece handle=/backups/al_t737969948_s8_p1 tag=TAG20101217T073908 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
Finished backup at 17-DEC-10

released channel: d1

RMAN>

Step 3: Create pfile & edit some required parameters

SQL> create pfile='/backups/initAUX.ora' from spfile;

File created.

SQL>

Edit& Save

*.audit_file_dest =/u01/app/oracle/AUX/adump
*.core_dump_dest =/u01/app/oracle/AUX/cdump
*.db_name ="AUX"
*.instance_name =AUX
*.control_files =/u01/app/oracle/AUX/control01.ctl
*.db_file_name_convert =("+DATA","/u01/app/oracle/AUX","+SPTEST","/u01/app/oracle/AUX")
*.log_file_name_convert =("+DATA","/u01/app/oracle/AUX")
*.undo_management =AUTO
*.undo_retention =10800
*.undo_tablespace='UNDOTBS1'
*.db_block_size=8192
*.compatible='11.2.0.0.0'

Step 4: startup nomount for AUX database

[oracle@localhost ~]$ export ORACLE_SID=AUX
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 17 09:14:09 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup nomount pfile='/backups/initAUX.ora';
ORACLE instance started.

Total System Global Area  146472960 bytes
Fixed Size                  1335080 bytes
Variable Size              92274904 bytes
Database Buffers           50331648 bytes
Redo Buffers                2531328 bytes
SQL>

Step 5:Create duplicate database from here

[oracle@localhost ~]$ export ORACLE_SID=AUX
[oracle@localhost ~]$ rman target sys/Admin123@azardb auxiliary /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 17 09:18:34 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: AZARDB (DBID=1655311948)
connected to auxiliary database: AUX (not mounted)

RMAN> run{
2> allocate auxiliary channel C1 device type disk;
3> duplicate target database to AUX;
4> }

using target database control file instead of recovery catalog
allocated channel: C1
channel C1: SID=20 device type=DISK

Starting Duplicate Db at 17-DEC-10

contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

contents of Memory Script:
{
sql clone "alter system set  db_name =
''AZARDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set  db_unique_name =
''AUX'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''AZARDB'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''AUX'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

Starting restore at 17-DEC-10

channel C1: starting datafile backup set restore
channel C1: restoring control file
channel C1: reading from backup piece /backups/df_t737969943_s7_p1
channel C1: piece handle=/backups/df_t737969943_s7_p1 tag=TAG20101217T073635
channel C1: restored backup piece 1
channel C1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/AUX/control01.ctl
Finished restore at 17-DEC-10

database mounted

contents of Memory Script:
{
set until scn  971599;
set newname for datafile  1 to
"/u01/app/oracle/AUX/azardb/datafile/system.256.736179685";
set newname for datafile  2 to
"/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685";
set newname for datafile  3 to
"/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685";
set newname for datafile  4 to
"/u01/app/oracle/AUX/azardb/datafile/users.256.737964169";
set newname for datafile  5 to
"/u01/app/oracle/AUX/azardb/datafile/example.269.736179971";
restore
clone database
;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-DEC-10

channel C1: starting datafile backup set restore
channel C1: specifying datafile(s) to restore from backup set
channel C1: restoring datafile 00001 to /u01/app/oracle/AUX/azardb/datafile/system.256.736179685
channel C1: restoring datafile 00002 to /u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
channel C1: restoring datafile 00003 to /u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
channel C1: restoring datafile 00004 to /u01/app/oracle/AUX/azardb/datafile/users.256.737964169
channel C1: restoring datafile 00005 to /u01/app/oracle/AUX/azardb/datafile/example.269.736179971
channel C1: reading from backup piece /backups/df_t737969795_s6_p1
channel C1: piece handle=/backups/df_t737969795_s6_p1 tag=TAG20101217T073635
channel C1: restored backup piece 1
channel C1: restore complete, elapsed time: 00:01:27
Finished restore at 17-DEC-10

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/system.256.736179685
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971

contents of Memory Script:
{
set until scn  971599;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 17-DEC-10

starting media recovery

archived log for thread 1 with sequence 12 is already on disk as file +DATA/azardb/archivelog/2010_12_17/thread_1_seq_12.279.737969947
archived log for thread 1 with sequence 13 is already on disk as file +DATA/azardb/archivelog/2010_12_17/thread_1_seq_13.280.737969949
archived log file name=+DATA/azardb/archivelog/2010_12_17/thread_1_seq_12.279.737969947 thread=1 sequence=12
archived log file name=+DATA/azardb/archivelog/2010_12_17/thread_1_seq_13.280.737969949 thread=1 sequence=13
media recovery complete, elapsed time: 00:00:00
Finished recover at 17-DEC-10

contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set  db_name =
''AUX'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset  db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

sql statement: alter system set  db_name =  ''AUX'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      3
MAXDATAFILES      100
MAXINSTANCES     8
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_1.262.736179919', '/u01/app/oracle/AUX/azardb/onlinelog/group_1.263.736179919' ) SIZE 50 M  REUSE,
GROUP  2 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_2.264.736179921', '/u01/app/oracle/AUX/azardb/onlinelog/group_2.265.736179925' ) SIZE 50 M  REUSE,
GROUP  3 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_3.266.736179927', '/u01/app/oracle/AUX/azardb/onlinelog/group_3.267.736179929' ) SIZE 50 M  REUSE
DATAFILE
'/u01/app/oracle/AUX/azardb/datafile/system.256.736179685'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:
{
set newname for tempfile  1 to
"/u01/app/oracle/AUX/azardb/tempfile/temp.268.736179955";
switch clone tempfile all;
catalog clone datafilecopy  "/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685",
"/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685",
"/u01/app/oracle/AUX/azardb/datafile/users.256.737964169",
"/u01/app/oracle/AUX/azardb/datafile/example.269.736179971";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/AUX/azardb/tempfile/temp.268.736179955 in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685 RECID=1 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685 RECID=2 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169 RECID=3 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971 RECID=4 STAMP=737976113

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=737976113 file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971

[oracle@localhost ~]$ export ORACLE_SID=AUX
[oracle@localhost ~]$ rman target sys/Admin123@azardb auxiliary /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 17 09:18:34 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: AZARDB (DBID=1655311948)
connected to auxiliary database: AUX (not mounted)

RMAN> run{
2> allocate auxiliary channel C1 device type disk;
3> duplicate target database to AUX;
4> }

using target database control file instead of recovery catalog
allocated channel: C1
channel C1: SID=20 device type=DISK

Starting Duplicate Db at 17-DEC-10

contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

contents of Memory Script:
{
sql clone "alter system set  db_name =
''AZARDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set  db_unique_name =
''AUX'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''AZARDB'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''AUX'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

Starting restore at 17-DEC-10

channel C1: starting datafile backup set restore
channel C1: restoring control file
channel C1: reading from backup piece /backups/df_t737969943_s7_p1
channel C1: piece handle=/backups/df_t737969943_s7_p1 tag=TAG20101217T073635
channel C1: restored backup piece 1
channel C1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/AUX/control01.ctl
Finished restore at 17-DEC-10

database mounted

contents of Memory Script:
{
set until scn  971599;
set newname for datafile  1 to
"/u01/app/oracle/AUX/azardb/datafile/system.256.736179685";
set newname for datafile  2 to
"/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685";
set newname for datafile  3 to
"/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685";
set newname for datafile  4 to
"/u01/app/oracle/AUX/azardb/datafile/users.256.737964169";
set newname for datafile  5 to
"/u01/app/oracle/AUX/azardb/datafile/example.269.736179971";
restore
clone database
;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-DEC-10

channel C1: starting datafile backup set restore
channel C1: specifying datafile(s) to restore from backup set
channel C1: restoring datafile 00001 to /u01/app/oracle/AUX/azardb/datafile/system.256.736179685
channel C1: restoring datafile 00002 to /u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
channel C1: restoring datafile 00003 to /u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
channel C1: restoring datafile 00004 to /u01/app/oracle/AUX/azardb/datafile/users.256.737964169
channel C1: restoring datafile 00005 to /u01/app/oracle/AUX/azardb/datafile/example.269.736179971
channel C1: reading from backup piece /backups/df_t737969795_s6_p1
channel C1: piece handle=/backups/df_t737969795_s6_p1 tag=TAG20101217T073635
channel C1: restored backup piece 1
channel C1: restore complete, elapsed time: 00:01:27
Finished restore at 17-DEC-10

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/system.256.736179685
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=737976075 file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971

contents of Memory Script:
{
set until scn  971599;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 17-DEC-10

starting media recovery

archived log for thread 1 with sequence 12 is already on disk as file +DATA/azardb/archivelog/2010_12_17/thread_1_seq_12.279.737969947
archived log for thread 1 with sequence 13 is already on disk as file +DATA/azardb/archivelog/2010_12_17/thread_1_seq_13.280.737969949
archived log file name=+DATA/azardb/archivelog/2010_12_17/thread_1_seq_12.279.737969947 thread=1 sequence=12
archived log file name=+DATA/azardb/archivelog/2010_12_17/thread_1_seq_13.280.737969949 thread=1 sequence=13
media recovery complete, elapsed time: 00:00:00
Finished recover at 17-DEC-10

contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set  db_name =
''AUX'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset  db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK

sql statement: alter system set  db_name =  ''AUX'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     146472960 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
allocated channel: C1
channel C1: SID=18 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      3
MAXDATAFILES      100
MAXINSTANCES     8
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_1.262.736179919', '/u01/app/oracle/AUX/azardb/onlinelog/group_1.263.736179919' ) SIZE 50 M  REUSE,
GROUP  2 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_2.264.736179921', '/u01/app/oracle/AUX/azardb/onlinelog/group_2.265.736179925' ) SIZE 50 M  REUSE,
GROUP  3 ( '/u01/app/oracle/AUX/azardb/onlinelog/group_3.266.736179927', '/u01/app/oracle/AUX/azardb/onlinelog/group_3.267.736179929' ) SIZE 50 M  REUSE
DATAFILE
'/u01/app/oracle/AUX/azardb/datafile/system.256.736179685'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:
{
set newname for tempfile  1 to
"/u01/app/oracle/AUX/azardb/tempfile/temp.268.736179955";
switch clone tempfile all;
catalog clone datafilecopy  "/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685",
"/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685",
"/u01/app/oracle/AUX/azardb/datafile/users.256.737964169",
"/u01/app/oracle/AUX/azardb/datafile/example.269.736179971";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/AUX/azardb/tempfile/temp.268.736179955 in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685 RECID=1 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685 RECID=2 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169 RECID=3 STAMP=737976112
cataloged datafile copy
datafile copy file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971 RECID=4 STAMP=737976113

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=737976112 file name=/u01/app/oracle/AUX/azardb/datafile/users.256.737964169
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=737976113 file name=/u01/app/oracle/AUX/azardb/datafile/example.269.736179971

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened

Duplicate database was successfully created

Step 6: Check Duplicate Database

[oracle@localhost ~]$ export ORACLE_SID=AUX
[oracle@localhost ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 17 09:25:45 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
---------
AUX

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/AUX/azardb/datafile/system.256.736179685
/u01/app/oracle/AUX/azardb/datafile/sysaux.257.736179685
/u01/app/oracle/AUX/azardb/datafile/undotbs1.258.736179685
/u01/app/oracle/AUX/azardb/datafile/users.256.737964169
/u01/app/oracle/AUX/azardb/datafile/example.269.736179971

SQL>

Possible Errors:

You can get some errors , cann’t restore datafile & onlineredo log files, in this case you need to create directory ,It should be indicate.

azardb/datafile

azardb/onlinelog

How to move ASM spfile from one diskgroup to another diskgroup

Here , I just showed you ,How to move ASM spfile from one diskgroup to another diskgroup.

before I have currently using one diskgroup, so i need to create another diskgroup using ASMCA, I just formated disk using fdisk command.

After created new diskgroup, follow the steps

[root@localhost ~]# su - oracle
[oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
[oracle@localhost ~]$ export PATH=/u01/app/oracle/product/11.2.0/grid/bin
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 16 11:46:32 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: sys/Admin123 as sysasm

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/asm/asmparameterfile/reg
istry.253.736177541
SQL> create pfile='/install/initASM.ora' from spfile;

File created.

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/asm/asmparameterfile/reg
istry.253.736177541
SQL> create spfile='+SPTEST' from pfile='/install/initASM.ora';

File created.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option
[oracle@localhost ~]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'localhost'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'localhost'
CRS-2673: Attempting to stop 'ora.SPTEST.dg' on 'localhost'
CRS-2673: Attempting to stop 'ora.azardb.db' on 'localhost'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'localhost' succeeded
CRS-2677: Stop of 'ora.SPTEST.dg' on 'localhost' succeeded
CRS-2677: Stop of 'ora.azardb.db' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'localhost'
CRS-2677: Stop of 'ora.DATA.dg' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'localhost'
CRS-2677: Stop of 'ora.asm' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'localhost'
CRS-2677: Stop of 'ora.cssd' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'localhost'
CRS-2677: Stop of 'ora.diskmon' on 'localhost' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'localhost' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[oracle@localhost ~]$
[oracle@localhost ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
[oracle@localhost ~]$ export PATH=/u01/app/oracle/product/11.2.0/grid/bin
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 16 11:57:30 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: sys/Admin123 as sysasm

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +SPTEST/asm/asmparameterfile/r
egistry.253.737898615
SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
SPTEST                         MOUNTED
DATA                           MOUNTED

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option

you can verify using asmcmd command

[oracle@localhost ~]$ asmcmd spget
+SPTEST/asm/asmparameterfile/registry.253.737898615

just remove old spfile from here

[[oracle@localhost ~]$ asmcmd rm +DATA/asm/asmparameterfile/registry.253.736177541
[oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
[oracle@localhost ~]$ export PATH=/u01/app/oracle/product/11.2.0/grid/bin
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 16 12:00:08 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: sys/Admin123 as sysasm

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +SPTEST/asm/asmparameterfile/r
egistry.253.737898615
SQL>

 

Rename and Relocate datafiles

This post will show you How to rename your datafiles and also relocate datafiles.

Rename Datafiles in Single Tablespace  (Database Open Mode) :-

Caution : Backup your tablespace Before you will do some change in your tablespace.

Step 1:  I just create tablespaces with two datafiles


SQL> create tablespace renametbs datafile 'd:\backup\renametbs01.dbf' size 50m;

Tablespace created.

SQL> alter tablespace renametbs add datafile 'd:\backup\renametbs02.dbf' size 50m;

Tablespace altered.

SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='RENAMETBS';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
D:\BACKUP\RENAMETBS01.DBF
RENAMETBS

D:\BACKUP\RENAMETBS02.DBF
RENAMETBS

Step 2: Tablespace Offline

SQL> alter tablespace renametbs offline normal;

Tablespace altered.

Step  3: Rename your datafile, Here you need to listen something , when you’re execute rename command, It will show some errors like below


L> alter tablespace renametbs rename datafile 'd:\backup\renametbs01.dbf','d:\backup\renametbs02.dbf' TO 'd:\backup\renametbs1.dbf','d:\backup\renametbs2.dbf

ter tablespace renametbs rename datafile 'd:\backup\renametbs01.dbf','d:\backup\renametbs02.dbf' TO 'd:\backup\renametbs1.dbf','d:\backup\renametbs2.dbf'

ROR at line 1:
A-01525: error in renaming data files
A-01141: error renaming data file 8 - new file 'd:\backup\renametbs1.dbf' not
und
A-01110: data file 8: 'D:\BACKUP\RENAMETBS01.DBF'
A-27041: unable to open file
D-04002: unable to open file
S-Error: (OS 2) The system cannot find the file specified.

What is this means, After tablespace offline, you need to copy and paste same location of your datafiles and rename manully (OS level) which name you will implement, Otherwise the system cannot find the files. 

SQL> alter tablespace renametbs rename datafile 'D:\BACKUP\RENAMETBS01.DBF','D:\BACKUP\RENAMETBS02.DBF' TO 'D:\BACKUP\RENAMETBS1.DBF','D:\BACKUP\RENAMETBS2.DBF
';

Tablespace altered.

Step 4: Tablespace Online and Take backup.


SQL> alter tablespace renametbs online;

Tablespace altered.

SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='RENAMETBS';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
D:\BACKUP\RENAMETBS1.DBF
RENAMETBS

D:\BACKUP\RENAMETBS2.DBF
RENAMETBS
SQL>

Relocate Datafiles in Single Tablespace (Database Open Mode) :

Step 1: Check your current Datafiles location


SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='RENAMETBS';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
D:\BACKUP\RENAMETBS1.DBF
RENAMETBS

D:\BACKUP\RENAMETBS2.DBF
RENAMETBS

Step 2: you need to know your datafiles size,

SQL> select file_name,bytes from dba_data_files where tablespace_name='RENAMETBS';

FILE_NAME
--------------------------------------------------------------------------------
     BYTES
----------
D:\BACKUP\RENAMETBS1.DBF
  52428800

D:\BACKUP\RENAMETBS2.DBF
  52428800

Step 3: Tablespace offline


SQL> alter tablespace renametbs offline normal;

Tablespace altered.

Step 4: Copy your datafiles to New location and Rename it manually (OS level).


SQL> alter tablespace renametbs rename datafile 'D:\BACKUP\RENAMETBS1.DBF','D:\BACKUP\RENAMETBS2.DBF' TO 'C:\RENAMETB\RENAMETBS1.DBF','C:\RENAMETB\RENAMETBS2.D
BF';

Tablespace altered.

Step 5:  After relocated , your current datafile location and tablespace online , take backup.


SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='RENAMETBS';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
C:\RENAMETB\RENAMETBS1.DBF
RENAMETBS

C:\RENAMETB\RENAMETBS2.DBF
RENAMETBS

SQL> alter tablespace renametbs online;

Tablespace altered.

SQL>

Rename Datafile for Multiple Tablespace  (Database Mount Mode):

Step 1: Startup mount


SQL> startup mount
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             209715664 bytes
Database Buffers          318767104 bytes
Redo Buffers                5804032 bytes
Database mounted.

Step 2: Check your datafile


SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSTEM01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSAUX01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\UNDOTBS01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\USERS01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\EXAMPLE01.DBF
D:\BACKUP\RCRMAN01.DBF
D:\BACKUP\USERSTBS01.DBF
C:\RENAMETB\RENAMETBS1.DBF
D:\BACKUP\TBSPITR01.DBF
C:\RENAMETB\RENAMETBS2.DBF
D:\BACKUP\TESTTB01.DBF

11 rows selected.

Here I choosed “C:\RENAMETB\RENAMETBS1.DBF ” to ” C:\RENAMETB\RENAMETBS01.DBF “, AS Same Like “D:\BACKUP\TESTTB01.DBF” to “D:\BACKUP\TESTTB1.DBF 

Step 3: Rename Datafile for multiple tablespace


SQL> alter database rename file 'C:\renametb\renametbs1.dbf','D:\backup\testtb01.dbf' to 'C:\renametb\renametbs01.dbf','D:\backup\testtb1.dbf';

Database altered.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSTEM01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\SYSAUX01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\UNDOTBS01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\USERS01.DBF
C:\APP\ORACLE\MAZAR\ORADATA\AZARDB\EXAMPLE01.DBF
D:\BACKUP\RCRMAN01.DBF
D:\BACKUP\USERSTBS01.DBF
C:\RENAMETB\RENAMETBS01.DBF
D:\BACKUP\TBSPITR01.DBF
C:\RENAMETB\RENAMETBS2.DBF
D:\BACKUP\TESTTB1.DBF

11 rows selected.

Step 4: Alter your database opened.


SQL> alter database open;

Database altered.

SQL> select file_name,tablespace_name from dba_data_files where tablespace_name in ('RENAMETBS','TESTTB');

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
C:\RENAMETB\RENAMETBS01.DBF
RENAMETBS

C:\RENAMETB\RENAMETBS2.DBF
RENAMETBS

D:\BACKUP\TESTTB1.DBF
TESTTB
SQL>

Refer :-

http://download.oracle.com/docs/cd/E11882_01/server.112/e17120/dfiles005.htm#i1006457

ORA-01552: cannot use system rollback segment for non-system tablespace ‘USERS’

When i try to insert one row into table, it shows following error

SQL> conn tbsptr/tbsptr;
Connected.
SQL> insert into x values(‘azar’);
insert into x values(‘azar’)
            *
ERROR at line 1:
ORA-01552: cannot use system rollback segment for non-system tablespace ‘USERS’

 

This error happened due to your undo tablespace.

If Undo tablespace is missed out in your database —> you need to recreate the undo tablespace

If Undo tablespace size is full

If Undo tablespace datafile offline. —> This is my case.

I have checked my undo tablespace status , it show online.

SQL> conn / as sysdba
Connected.
SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
—————————— ———
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1               ONLINE
TEMP                           ONLINE

I just checked  my undo tablespace free space also , it shows 484 MB

SQL> SELECT tablespace_name, sum((bytes/1024)/1024) free FROM DBA_FREE_SPACE group by tablespace_name;

TABLESPACE_NAME                      FREE
—————————— ———-
SYSAUX                            136.125
UNDOTBS1                         484.5625

Finally I forget to see Undo tablespace datafile status,

Now I check

SQL> select file#,status from v$datafile;

     FILE# STATUS
———- ——-
         1 SYSTEM
         2 ONLINE
         3 OFFLINE         

OOPS This is the issues for me, Now I want to alter this tablespace as  online.

 

SQL> alter database datafile ‘C:\APP\MAZAR\ORADATA\OWN\UNDOTBS01.DBF’ online;

Database altered.

SQL> commit;

Commit complete.

SQL> conn tbsptr/tbsptr;
Connected.
SQL> insert into x values(‘azar’);

1 row created.

Now I can able to insert my data into tables. 🙂

RMAN : Restoring datafiles to Nondefault locations

 You have just experiences a serious media failure and won’t able to restore datafiles to their original location.In this case, you need to restore datafiles to a nondafault location.

You can use set newname and switch commands to restore datafiles to nondefault locations. You must set newname command and the switch command from within a run{} block. 
The switch command updates the target database controlfile with new location of the datafile. It’s OK to use switch datafile all, which updates all datafile locations.

If you are  performing  Point in time recovery (POITR) ensure you switch datafiles before you perform the recovery.

Now we can see the examples.
I have created one tablespace.Its name TEST with two datafiles test01.dbf,test02.dbf
The location is
                                                
C:\APP\MAZAR\ORADATA\OWN\TEST01.DBF (6) –> C:\APP\MAZAR\ORADATA\OWN\new\TEST01.DBF (Target new location)
        

C:\APP\MAZAR\ORADATA\OWN\TEST02.DBF (7) –> C:\APP\MAZAR\ORADATA\OWN\new\TEST02.DBF (Target new location)

       
6,7 Datafile ID

startup mount stage

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area 1046224896 bytes
Fixed Size                  1379212 bytes
Variable Size             167773300 bytes
Database Buffers          872415232 bytes
Redo Buffers                4657152 bytes
Database mounted.
SQL> host
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\mazar>rman target /

Recovery Manager: Release 11.2.0.1.0 – Production on Wed Sep 1 11:31:13 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: OWN (DBID=1547349083, not open)

RMAN> run{
2> set newname for datafile 6 to ‘C:\APP\MAZAR\ORADATA\OWN\new/test01.dbf’;
3> set newname for datafile 7 to ‘C:\APP\MAZAR\ORADATA\OWN\new\test02.dbf’;
4> restore tablespace “TEST”;
5> switch datafile all;
6> recover tablespace “TEST”;
7> alter database open;
8> }

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 01-SEP-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK

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 00006 to C:\APP\MAZAR\ORADATA\OWN\new/tes
t01.dbf
channel ORA_DISK_1: restoring datafile 00007 to C:\APP\MAZAR\ORADATA\OWN\new\tes
t02.dbf
channel ORA_DISK_1: reading from backup piece C:\APP\MAZAR\FLASH_RECOVERY_AREA\O
WN\BACKUPSET\2010_09_01\O1_MF_NNNDF_TAG20100901T112433_67W3G28B_.BKP
channel ORA_DISK_1: piece handle=C:\APP\MAZAR\FLASH_RECOVERY_AREA\OWN\BACKUPSET\
2010_09_01\O1_MF_NNNDF_TAG20100901T112433_67W3G28B_.BKP tag=TAG20100901T112433
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 01-SEP-10

datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=728566586 file name=C:\APP\MAZAR\ORADATA\OWN\N
EW\TEST01.DBF
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=728566586 file name=C:\APP\MAZAR\ORADATA\OWN\N
EW\TEST02.DBF

Starting recover at 01-SEP-10
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 01-SEP-10

database opened

If the database is open, you can place the datafile offline and then set their new names for restore and recovery.

RMAN> run{
2> sql ‘alter database datafile 6,7 offline’;
3> set newname for datafile 6 to ‘C:\APP\MAZAR\ORADATA\OWN\new\test01.dbf’;
4> set newname for datafile 7 to ‘C:\APP\MAZAR\ORADATA\OWN\new\test02.dbf’;
5> restore datafile 6,7;
6> switch datafile all;
7> recover datafile 6,7;
8> sql ‘alter database datafile 6,7 online’;
9> }

sql statement: alter database datafile 6,7 offline

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 01-SEP-10
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00006
input datafile copy RECID=5 STAMP=728566586 file name=C:\APP\MAZAR\ORADATA\OWN\T
EST01.DBF
destination for restore of datafile 00006: C:\APP\MAZAR\ORADATA\OWN\new\test01.d
bf
channel ORA_DISK_1: copied datafile copy of datafile 00006
output file name=C:\APP\MAZAR\ORADATA\OWN\NEW\TEST01.DBF RECID=0 STAMP=0
channel ORA_DISK_1: restoring datafile 00007
input datafile copy RECID=6 STAMP=728566586 file name=C:\APP\MAZAR\ORADATA\OWN\T
EST02.DBF
destination for restore of datafile 00007: C:\APP\MAZAR\ORADATA\OWN\new\test02.d
bf
channel ORA_DISK_1: copied datafile copy of datafile 00007
output file name=C:\APP\MAZAR\ORADATA\OWN\NEW\TEST02.DBF RECID=0 STAMP=0
Finished restore at 01-SEP-10
Starting recover at 01-SEP-10
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 01-SEP-10

sql statement: alter database datafile 6,7 online

RMAN>

You can check the new datafiles locations using report schema command.

RMAN> report schema;

Report of database schema for database with db_unique_name OWN

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
—- ——– ——————– ——- ————————
1    700      SYSTEM               ***     C:\APP\MAZAR\ORADATA\OWN\SYSTEM01.DBF

2    600      SYSAUX               ***     C:\APP\MAZAR\ORADATA\OWN\SYSAUX01.DBF

3    500      UNDOTBS1             ***     C:\APP\MAZAR\ORADATA\OWN\UNDOTBS01.DBF
4    5        USERS                ***     C:\APP\MAZAR\ORADATA\OWN\USERS01.DBF
5    100      RMAN001              ***     C:\APP\MAZAR\ORADATA\OWN\RMAN01.DBF
6    100      TEST                 ***     C:\APP\MAZAR\ORADATA\OWN\NEW\TEST01.DBF
7    100      TEST                 ***     C:\APP\MAZAR\ORADATA\OWN\NEW\TEST02.DBF

and also you can check from v$datafile view.