通过不完全恢复解决用户的误操作:
SQL> archive log list
备份前工作:
SQL> create table t1(x varchar2(50)) tablespace users;
SQL> insert into t1 values ('before backup');
SQL> commit;
备份:
RMAN> backup database tag 'weekend_DB_full_backup';
备份后:
SQL> insert into t1 values ('after backup, before delete');
SQL> commit;
误操作:
SQL> select sysdate from dual;
SQL> select dbms_flashback.get_system_change_number from dual;查看号码
SQL> delete t1;
SQL> commit;
SQL> create table after_delete (x int); 正确的操作
SQL> insert into after_delete values (1);
SQL> commit;
恢复:
RMAN> run {
startup force mount;
set until scn= 1806683;
restore database;
recover database;
alter database open resetlogs;
}
set until time=’2015-10-26 11:13:23’; 基于时间点恢复
SQL> select * from t1;
SQL> select * from after_delete; 丢失
SQL> select group#, sequence#, status, archived from v$log;
通过不完全恢复解决归档日志不连续:
SQL> archive log list
备份前:
SQL> create table t1(x varchar2(50)) tablespace users;
SQL> insert into t1 values ('before backup');
SQL> commit;
备份:
RMAN> backup database tag 'weekend_DB_full_backup';
备份后:
SQL> select GROUP#, SEQUENCE#, STATUS, archived from v$log;
SQL> insert into t1 values ('after backup, logseq 1, archived');
SQL> commit;
SQL> alter system switch logfile;
SQL> insert into t1 values ('after backup, logseq 2, archived');
SQL> commit;
SQL> alter system switch logfile;
SQL> insert into t1 values ('after backup, logseq 3, archived');
SQL> commit;
SQL> alter system switch logfile;
SQL> insert into t1 values ('after backup, logseq 4, archived');
SQL> commit;
SQL> alter system switch logfile;
SQL> insert into t1 values ('after backup, logseq 5, current');
SQL> commit;
SQL> alter system checkpoint;
故障:
SQL> shutdown abort
$ rm /u01/app/oracle/oradata/orcl/users01.dbf
$rm/u01/app/oracle/fast_recovery_area/ORCL/archivelog/2016_03_01/o1_mf_1_5_cfbcxo84_.arc
恢复:
SQL> startup
先尝试只恢复一个数据文件失败。
RMAN> run {
startup force mount;
set until sequence 4;
restore database;
recover database;
alter database open resetlogs;
}
SQL> select * from t1;