RMAN不完全恢复方法
3.删除一个表:SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YY-------------------2018-05-09 15:37:15
drop table emp purge;
4.如果在删除前没有做时间的记录,可以通过日志挖掘来找出删除的时间或scn:
SQL> exec dbms_logmnr.add_logfile('/home/oracle/app/oracle/oradata/orcl/redo01.log'); (这里的日志如果是归档日志,也可用同样的方法添加进去)
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
PL/SQL procedure successfully completed.
SQL> select scn,to_char(timestamp,'yyyy-mm-dd hh24:mi:ss') time,sql_redo from v$logmnr_contents where table_name='EMP';
SCN TIME SQL_REDO
--------------------------------------------------------------------------------
1201958 2018-05-09 15:37:26 drop table emp purge;
SQL> exec dbms_logmnr.end_logmnr;
5.通过RMAN来恢复到指定时间点
RMAN> shutdown immediate
RMAN> startup mount
RMAN> run {
2> set until time "to_date('2018-05-09 15:37:25','yyyy-mm-dd hh24:mi:ss')";
3> restore database;
4> recover database;
5> alter database open resetlogs;
6> }
executing command: SET until clause
Starting restore at 09-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=7 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 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_09/o1_mf_nnndf_TAG20180509T153541_fh596frb_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_09/o1_mf_nnndf_TAG20180509T153541_fh596frb_.bkp tag=TAG20180509T153541
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 09-MAY-18
Starting recover at 09-MAY-18
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 09-MAY-18
至此,已完成恢复到指定时间点,在去查emp表的时,可以发现已经恢复。database opened