You are on page 1of 17

Accidentally dropped table: Recovery using RMAN cloning

http://dbarajabaskar.blogspot.com/

Dropped table recovery using RMAN Cloning

Rajabaskar Thangaraj

Mail me: rajabaskar.t@gmail.com

www.dbarajabaskar.blogspot.com

1
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

A user accidentally dropped a table in production database. We have a proper RMAN backup.

Normally we follow the below steps for recovery:

1. Offline the datafiles/tablespace belonging to table.


2. Restore the datafiles/tablespace.
3. Recover the datafiles.

For this we need an outage for the application. So we using prior backup to clone the database &
export the table and import into production. Our database is very huge database. So restoration is
very difficult.

That time we used skip tablespace feature. Restore the corresponding tablespace, system, and undo
& sysaux tablespace. To reduce the restoration downtime & avoid the space issue.

I have tested this scenario in my test server.

Environment Details:

Operating system: Windows XP service pack 2

Database Version: 11.1.0.7 (32 bit)

Source database name: che

Clone database name: clonedb

How its work?

RMAN before restore the datafiles its skip the mentioned skip tablespace belonging datafiles.
That datafiles are offline before restore operation is performed. After recovery, its remove the
skip tablespace information from current control file.

We will create two users & 4 tablespaces.

1. Login into CHE database

----created new tablespaces

SQL> create tablespace raja_data


2 datafile 'D:\ORACLE\APP\ORADATA\CHE\raja_data01.dbf' size 100m;

Tablespace created.

SQL> create tablespace raja_indx


2 datafile 'D:\ORACLE\APP\ORADATA\CHE\raja_indx01.dbf' size 50m;

2
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

Tablespace created.

----created new user

SQL> create user raja identified by raja


2 default tablespace RAJA_DATA
3 quota unlimited on RAJA_DATA
4 quota unlimited on RAJA_INDX;

User created.

SQL> grant connect, resource, dba to raja;

Grant succeeded.

SQL> create table raja.objects as select * from dba_objects;

Table created.

SQL> create index raja.object_id_indx on raja.objects(object_id) tablespace raja_indx;

Index created.

----created new tablespaces

SQL> create tablespace test_data


2 datafile 'D:\ORACLE\APP\ORADATA\CHE\test_data01.dbf' size 100m;

Tablespace created.

SQL> create tablespace test_indx


2 datafile 'D:\ORACLE\APP\ORADATA\CHE\test_indx01.dbf' size 50m;

Tablespace created.

----created new user

SQL> create user baskar identified by baskar


2 default tablespace TEST_DATA
3 quota unlimited on TEST_DATA
4 quota unlimited on TEST_INDX;

User created.

SQL> grant connect, resource, dba to baskar;

Grant succeeded.

3
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

SQL> create table baskar.objects as select * from dba_objects;

Table created.

SQL> create index baskar.bas_object_id_indx on baskar.objects(object_id)


tablespace test_indx;

Index created.

SQL> select segment_name,segment_type,tablespace_name from dba_segments where


owner in ('RAJA','BASKAR');

SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME


-------------------- ------------------ --------------------
OBJECTS TABLE RAJA_DATA
OBJECT_ID_INDX INDEX RAJA_INDX
OBJECTS TABLE TEST_DATA
BAS_OBJECT_ID_INDX INDEX TEST_INDX

SQL> select tablespace_name, file_name from dba_data_files;

TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------
-
USERS D:\ORACLE\APP\ORADATA\CHE\USERS01.DBF
UNDOTBS1 D:\ORACLE\APP\ORADATA\CHE\UNDOTBS01.DBF
SYSAUX D:\ORACLE\APP\ORADATA\CHE\SYSAUX01.DBF
SYSTEM D:\ORACLE\APP\ORADATA\CHE\SYSTEM01.DBF
EXAMPLE D:\ORACLE\APP\ORADATA\CHE\EXAMPLE01.DBF
RAJA_DATA D:\ORACLE\APP\ORADATA\CHE\RAJA_DATA01.DBF
RAJA_INDX D:\ORACLE\APP\ORADATA\CHE\RAJA_INDX01.DBF
TEST_DATA D:\ORACLE\APP\ORADATA\CHE\TEST_DATA01.DBF
TEST_INDX D:\ORACLE\APP\ORADATA\CHE\TEST_INDX01.DBF

9 rows selected.

2. Backup the target database ( CHE database)

C:\>set oracle_sid=che

C:\>rman

Recovery Manager: Release 11.1.0.7.0 - Production on Thu May 13 17:13:30 2010

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

RMAN> connect target sys@che

4
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

target database Password:


connected to target database: CHE (DBID=3460503574)

RMAN> backup database plus archivelog;

Starting backup at 13-MAY-10


current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=121 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=718909066
input archived log thread=1 sequence=3 RECID=2 STAMP=718910034
channel ORA_DISK_1: starting piece 1 at 13-MAY-10
channel ORA_DISK_1: finished piece 1 at 13-MAY-10
piece
handle=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\BACKUPSET\2010_05_13\O1_MF_AN
NNN_TAG20100513T171356_5YQSHX1Y_.BKP tag=TAG20100513T171356 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
Finished backup at 13-MAY-10

Starting backup at 13-MAY-10


using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=D:\ORACLE\APP\ORADATA\CHE\SYSTEM01.DBF
input datafile file number=00002 name=D:\ORACLE\APP\ORADATA\CHE\SYSAUX01.DBF
input datafile file number=00005 name=D:\ORACLE\APP\ORADATA\CHE\EXAMPLE01.DBF
input datafile file number=00006 name=D:\ORACLE\APP\ORADATA\CHE\RAJA_DATA01.DBF
input datafile file number=00008 name=D:\ORACLE\APP\ORADATA\CHE\TEST_DATA01.DBF
input datafile file number=00003 name=D:\ORACLE\APP\ORADATA\CHE\UNDOTBS01.DBF
input datafile file number=00007 name=D:\ORACLE\APP\ORADATA\CHE\RAJA_INDX01.DBF
input datafile file number=00009 name=D:\ORACLE\APP\ORADATA\CHE\TEST_INDX01.DBF
input datafile file number=00004 name=D:\ORACLE\APP\ORADATA\CHE\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 13-MAY-10
channel ORA_DISK_1: finished piece 1 at 13-MAY-10
piece
handle=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\BACKUPSET\2010_05_13\O1_MF_NN
NDF_TAG20100513T171404_5YQSJ5TV_.BKP tag=TAG20100513T171404 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 13-MAY-10
channel ORA_DISK_1: finished piece 1 at 13-MAY-10

5
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

piece
handle=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\BACKUPSET\2010_05_13\O1_MF_NC
SNF_TAG20100513T171404_5YQSLKSD_.BKP tag=TAG20100513T171404 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-MAY-10

Starting backup at 13-MAY-10


current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=3 STAMP=718910123
channel ORA_DISK_1: starting piece 1 at 13-MAY-10
channel ORA_DISK_1: finished piece 1 at 13-MAY-10
piece
handle=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\BACKUPSET\2010_05_13\O1_MF_AN
NNN_TAG20100513T171523_5YQSLMWB_.BKP tag=TAG20100513T171523 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-MAY-10

3. Configure the network files.

Listener configuration:

SID_LIST_LISTENER11G=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=che)
(SID_NAME=che)
(ORACLE_HOME=D:\Oracle\app\11.1.0\db_1)
)
(SID_DESC=
(GLOBAL_DBNAME=clonedb)
(SID_NAME=clonedb)
(ORACLE_HOME=D:\Oracle\app\11.1.0\db_1)
)
)
)

TNS configuration:

CHE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = che)(PORT = 1522))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = che)
)

6
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

CLONEDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = che)(PORT = 1522))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = clonedb)
)
)

4. Create the instance using oradim utility ( applicable for windows platform)

C:\>oradim -new -sid clonedb


Instance created.

5. Create a password file for clonedb database using orapwd utility

C:\>orapwd file=D:\Oracle\app\11.1.0\db_1\dbs\orapwCLONEDB
password=clonedbadmin entries=20

6. Create the init. ora file for clonedb database.

Che database: We create the pfile for clonedb from che database & edit the parameter.

SQL> show parameter spfile

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
spfile string D:\ORACLE\APP\11.1.0\D
B_1\DATABASE\SPFILECHE.ORA

SQL> create pfile='D:\Oracle\app\admin\clonedb\pfile\initclonedb.ora'


from spfile;

File created.

Init parameter change “clonedb” instead of che & use to start the Clonedb.

clonedb.__db_cache_size=130023424
clonedb.__java_pool_size=12582912
clonedb.__large_pool_size=4194304
clonedb.__oracle_base='D:\Oracle\app'#ORACLE_BASE set from environment
clonedb.__pga_aggregate_target=192937984
clonedb.__sga_target=348127232
clonedb.__shared_io_pool_size=0

7
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

clonedb.__shared_pool_size=184549376
clonedb.__streams_pool_size=8388608
*.audit_file_dest='D:\Oracle\app\admin\clonedb\adump'
*.audit_trail='db'
*.compatible='11.1.0.0.0'
*.control_files='D:\Oracle\app\oradata\clonedb\control01.ctl','D:\Oracle\app\oradata\clone
db\control02.ctl','D:\Oracle\app\oradata\clonedb\control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='clonedb'
*.diagnostic_dest='D:\Oracle\app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=clonedbXDB)'
*.log_archive_dest='D:\Oracle\app\archive\clonedb'
*.log_archive_start=TRUE
*.memory_target=538968064
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.skip_unusable_indexes=TRUE
*.undo_tablespace='UNDOTBS1'
db_file_name_convert =
('D:\ORACLE\APP\ORADATA\CHE','D:\ORACLE\APP\ORADATA\CLONEDB')
log_file_name_convert =
('D:\ORACLE\APP\ORADATA\CHE','D:\ORACLE\APP\ORADATA\CLONEDB')

7. Create the appropriate folder for clonedb database (admin/oradata folders etc..)

8. Startup the clone database in mount stage

C:\>set oracle_sid=clonedb

C:\>sqlplus

SQL*Plus: Release 11.1.0.7.0 - Production on Thu May 13 17:16:31 2010

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

Enter user-name: / as sysdba


Connected to an idle instance.

SQL> startup nomount


ORACLE instance started.

Total System Global Area 535662592 bytes


Fixed Size 1348508 bytes
Variable Size 398462052 bytes
Database Buffers 130023424 bytes
Redo Buffers 5828608 bytes

8
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

9. Login into CHE database

SQL> select owner,segment_name,segment_type,tablespace_name from


dba_segments where owner in ('RAJA','BASKAR');

OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME


---------- -------------------- ------------------ -----------------
---
RAJA OBJECTS TABLE RAJA_DATA
RAJA OBJECT_ID_INDX INDEX RAJA_INDX
BASKAR OBJECTS TABLE TEST_DATA
BASKAR BAS_OBJECT_ID_INDX INDEX TEST_INDX

Here we dropped the RAJA.OBJECTS table accidentally ☺

SQL> select to_char(SYSDATE,'dd-mm-yyyy hh24:mi:ss') "DATE" from dual;

DATE
-------------------
13-05-2010 17:27:20

SQL> drop table raja.objects;

Table dropped.

While recovery, we cloning the database & skip the remaining tablespace (TEST_DATA,
TEST_INDX)

10.Connect the target & auxiliary database using RMAN

C:\>rman target sys/cheadmin@che

Recovery Manager: Release 11.1.0.7.0 - Production on Thu May 13 17:29:19 2010

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

connected to target database: CHE (DBID=3460503574)

RMAN> connect auxiliary sys/clonedbadmin@clonedb

connected to auxiliary database: CLONEDB (not mounted)

RMAN> run
2> {
3> set until time "to_date('13-05-2010 17:27:20','dd-mm-yyyy hh24:mi:ss')";
4> DUPLICATE TARGET DATABASE TO CLONEDB SKIP TABLESPACE TEST_DATA, TEST_INDX;

9
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

5> }

executing command: SET until clause


using target database control file instead of recovery catalog

Starting Duplicate Db at 13-MAY-10


allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=152 device type=DISK
Datafile 8 skipped by request
Datafile 9 skipped by request

contents of Memory Script:


{
set until scn 930390;
set newname for datafile 1 to
"D:\ORACLE\APP\ORADATA\CLONEDB\SYSTEM01.DBF";
set newname for datafile 2 to
"D:\ORACLE\APP\ORADATA\CLONEDB\SYSAUX01.DBF";
set newname for datafile 3 to
"D:\ORACLE\APP\ORADATA\CLONEDB\UNDOTBS01.DBF";
set newname for datafile 4 to
"D:\ORACLE\APP\ORADATA\CLONEDB\USERS01.DBF";
set newname for datafile 5 to
"D:\ORACLE\APP\ORADATA\CLONEDB\EXAMPLE01.DBF";
set newname for datafile 6 to
"D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_DATA01.DBF";
set newname for datafile 7 to
"D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_INDX01.DBF";
restore
clone database
skip tablespace "TEST_INDX",
"TEST_DATA" ;
}
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
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 13-MAY-10


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

10
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

channel ORA_AUX_DISK_1: restoring datafile 00001 to D:\ORACLE\APP\ORADATA\CLONED


B\SYSTEM01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00002 to D:\ORACLE\APP\ORADATA\CLONED
B\SYSAUX01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00003 to D:\ORACLE\APP\ORADATA\CLONED
B\UNDOTBS01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00004 to D:\ORACLE\APP\ORADATA\CLONED
B\USERS01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00005 to D:\ORACLE\APP\ORADATA\CLONED
B\EXAMPLE01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00006 to D:\ORACLE\APP\ORADATA\CLONED
B\RAJA_DATA01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00007 to D:\ORACLE\APP\ORADATA\CLONED
B\RAJA_INDX01.DBF
channel ORA_AUX_DISK_1: reading from backup piece D:\ORACLE\APP\FLASH_RECOVERY_A
REA\CHE\BACKUPSET\2010_05_13\O1_MF_NNNDF_TAG20100513T171404_5YQSJ5TV_.BKP
channel ORA_AUX_DISK_1: piece handle=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\BACKU
PSET\2010_05_13\O1_MF_NNNDF_TAG20100513T171404_5YQSJ5TV_.BKP
tag=TAG20100513T171
404
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 13-MAY-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVE
LOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 2 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 3 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'D:\ORACLE\APP\ORADATA\CLONEDB\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:


{
switch clone datafile all;
}
executing Memory Script

datafile 2 switched to datafile copy


input datafile copy RECID=1 STAMP=718911767 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\SYSAUX01.DBF

11
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

datafile 3 switched to datafile copy


input datafile copy RECID=2 STAMP=718911767 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=718911767 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=718911768 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\EXAMPLE01.DBF
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=718911768 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\RAJA_DATA01.DBF
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=718911768 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\RAJA_INDX01.DBF

contents of Memory Script:


{
set until time "to_date('13-05-2010 17:27:20','dd-mm-yyyy hh24:mi:ss')";
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 13-MAY-10


using channel ORA_AUX_DISK_1
datafile 8 not processed because file is offline
datafile 9 not processed because file is offline

starting media recovery

archived log for thread 1 with sequence 4 is already on disk as file D:\ORACLE\A
PP\FLASH_RECOVERY_AREA\CHE\ARCHIVELOG\2010_05_13\O1_MF_1_4_5YQSLM4W_.ARC
archived log for thread 1 with sequence 5 is already on disk as file D:\ORACLE\A
PP\FLASH_RECOVERY_AREA\CHE\ARCHIVELOG\2010_05_13\O1_MF_1_5_5YQTW4H4_.ARC
archived log file name=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\ARCHIVELOG\2010_05_
13\O1_MF_1_4_5YQSLM4W_.ARC thread=1 sequence=4
archived log file name=D:\ORACLE\APP\FLASH_RECOVERY_AREA\CHE\ARCHIVELOG\2010_05_
13\O1_MF_1_5_5YQTW4H4_.ARC thread=1 sequence=5
media recovery complete, elapsed time: 00:00:04
Finished recover at 13-MAY-10

contents of Memory Script:


{

12
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

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 535662592 bytes

Fixed Size 1348508 bytes


Variable Size 201329764 bytes
Database Buffers 327155712 bytes
Redo Buffers 5828608 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVE
LOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 2 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 3 ( 'D:\ORACLE\APP\ORADATA\CLONEDB\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'D:\ORACLE\APP\ORADATA\CLONEDB\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:


{
set newname for tempfile 1 to
"D:\ORACLE\APP\ORADATA\CLONEDB\TEMP01.DBF";
switch clone tempfile all;
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\SYSAUX01.DBF";
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\UNDOTBS01.DBF";
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\USERS01.DBF";
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\EXAMPLE01.DBF";
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_DATA01.DBF";
catalog clone datafilecopy "D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_INDX01.DBF";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to D:\ORACLE\APP\ORADATA\CLONEDB\TEMP01.DBF in control file

13
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\SYSAUX01.DBF RECID=1 STAMP
=718911795

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\UNDOTBS01.DBF RECID=2 STAM
P=718911797

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\USERS01.DBF RECID=3 STAMP=
718911797

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\EXAMPLE01.DBF RECID=4 STAM
P=718911798

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_DATA01.DBF RECID=5 ST
AMP=718911798

cataloged datafile copy


datafile copy file name=D:\ORACLE\APP\ORADATA\CLONEDB\RAJA_INDX01.DBF RECID=6 ST
AMP=718911799

datafile 2 switched to datafile copy


input datafile copy RECID=1 STAMP=718911795 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=718911797 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=718911797 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=718911798 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\EXAMPLE01.DBF
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=718911798 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\RAJA_DATA01.DBF
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=718911799 file name=D:\ORACLE\APP\ORADATA\CLON
EDB\RAJA_INDX01.DBF

contents of Memory Script:


{
Alter clone database open resetlogs;
}

14
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

executing Memory Script


database opened
contents of Memory Script:
{
# drop offline and skipped tablespaces
sql clone 'drop tablespace "TEST_INDX" including contents cascade constraints';
# drop offline and skipped tablespaces
sql clone 'drop tablespace "TEST_DATA" including contents cascade constraints';
}
executing Memory Script
sql statement: drop tablespace "TEST_INDX" including contents cascade constraints
sql statement: drop tablespace "TEST_DATA" including contents cascade constraints
Finished Duplicate Db at 13-MAY-10

10. Verify the clonedb database.

SQL> select instance_name, host_name from v$instance;

INSTANCE_NAME HOST_NAME
---------------- --------------------
clonedb ARULMOZHIVARMA

SQL> select owner, segment_name, segment_type, tablespace_name from


dba_segments where owner in ('RAJA','BASKAR');

OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME


-------------------- --------------- --------------- --------------------
RAJA OBJECTS TABLE RAJA_DATA
RAJA OBJECT_ID_INDX INDEX RAJA_INDX

11. Export the table from CLONEDB & import into CHE database.

Export the table

D:\>set oracle_sid=clonedb

D:\>exp file=drop_table.dmp log=drop_table.log TABLES=('RAJA.OBJECTS')

Export: Release 11.1.0.7.0 - Production on Thu May 13 18:01:19 2010

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

Username: raja/raja

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table OBJECTS 69261 rows exported
Export terminated successfully without warnings.

15
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

Import the table

D:\>set oracle_sid=che

D:\>imp file=drop_table.dmp log=imp_drop_table.log fromuser=RAJA touser=RAJA

Import: Release 11.1.0.7.0 - Production on Thu May 13 18:02:10 2010

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

Username: raja/raja

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export file created by EXPORT:V11.01.00 via conventional path
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. importing RAJA's objects into RAJA
. . importing table "OBJECTS" 69261 rows imported
Import terminated successfully without warnings.

Login into CHE database & verify the table.

SQL> select instance_name,host_name from v$instance;

INSTANCE_NAME HOST_NAME
---------------- -----------------------------------------------------------
che ARULMOZHIVARMA

SQL> select owner, segment_name, segment_type, tablespace_name from dba_segments


Where owner in ('RAJA','BASKAR');

OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME


---------- -------------------- ------------------ -----------------
RAJA OBJECTS TABLE RAJA_DATA
RAJA OBJECT_ID_INDX INDEX RAJA_INDX
BASKAR OBJECTS TABLE TEST_DATA
BASKAR BAS_OBJECT_ID_INDX INDEX TEST_INDX

A user dropped a table accidentally. At least we know anyone time/sequence/SCN, & easily
recovered the table.

W e don’t know the exact time that table was dropped. How can we find?
U just refresh about LOGMINER utility ☺

Using LOGMINER to analyze the online redo log files or archived log files & find the SCN.

16
Accidentally dropped table: Recovery using RMAN cloning
http://dbarajabaskar.blogspot.com/

RMAN> run
2> {
3> set until scn scnnumber;
4> DUPLICATE TARGET DATABASE TO CLONEDB SKIP TABLESPACE TEST_DATA, TEST_INDX;
5> }

We will see the above scenario in another article.

I Hope this article helped to you. Suggestions are welcome.

Best Regards
RajaBaskar Thangaraj
www.dbarajabaskar.blogspot.com
Mail me: rajabaskar.t@gmail.com

17

You might also like