Thursday 12 September 2013

Recover deleted table from rman backup

If your backup is of night and your table droped in the morning then you can do as below,

1. restore database.
2. recover database until (cancel/scn/time). if you know the scn number before the table was dropped or time when it was dropped.
3. alter database open resetlogs.  As it is an incomplete recovery.


SQL> create table TEST2 as select * from emp;


Table created.


SQL> select count(*) from TEST2;


  COUNT(*)
----------
        15


SQL> select TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS') from dual;


TO_CHAR(SYSDATE,'DD-
--------------------
10-SEP-2013 10:57:05


SQL> alter system switch logfile;


System altered.


SQL> drop table TEST2 purge;


Table dropped.


SQL> shu immediate


[oracle@vnode MYSHELL]$ rman target /


Recovery Manager: Release 11.2.0.2.0 - Production on Tue Sep 10 10:58:39 2013


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


connected to target database: DDTEST (DBID=1667776968, not open)


RMAN> run{
set until time "to_date('2013 Sep 10 10:57','yyyy mon dd hh24:mi')";
restore database;
recover database;
alter database open resetlogs;
}2> 3> 4> 5> 6>
...........
...........
media recovery complete, elapsed time: 00:00:02
Finished recover at 10-SEP-13
database opened


RMAN> exit


SQL> set lin 200 pages 100
SQL> select count(*) from test2;


  COUNT(*)
----------
        15

No comments:

Post a Comment