案例2——恢複過去某個時間點誤操作的表(DML)
1、基於change (scn)
SQL> conn scott/tiger
Connected.
SQL> select * from tb01;
ID
----------
1
2
3
SQL> drop table tb01 purge;
Table dropped.
SQL> create table tb01(id int) tablespace test;
Table created.
SQL> insert into tb01 values(1);
1 row created.
SQL> commit;
Commit complete.
——通過logmr 分析出誤操作的scn
SQL> select username,scn,timestamp,sql_redo from v$logmnr_contents
2 where username='SCOTT' and lower(sql_redo) like '%table%';
USERNAME SCN TIMESTAMP SQL_REDO
---------- ---------- ------------------- --------------------------------------------------
SCOTT 851229 2012-03-23 15:45:22 drop table tb01 purge;
SCOTT 851264 2012-03-23 15:45:45 create table tb01(id int) tablespace test;
——這是一種偷懶的方法,在生產環境不能使用
05:52:30 SQL> select current_scn from v$database; //datablock 記錄的scn
CURRENT_SCN
-----------
1260285
——test 表裡的記錄
SQL> select * from scott.tb01;
ID
----------
1
2、進行基於change的恢複
——在mount狀態,進行restore 和recover
——restore 所有的datafile
SQL> startup force mount
ORACLE instance started.
Total System Global Area 314572800 bytes
查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/
Fixed Size 1279964 bytes
Variable Size 58722340 bytes
Database Buffers 251658240 bytes
Redo Buffers 2912256 bytes
Database mounted.
SQL> !
[oracle@solaris10 ~]$cp /disk1/backup/anny/cold_bak/*.dbf /u01/app/oracle/oradata/anny/
SQL> select file#,checkpoint_change# from v$datafile;——控制檔案的scn號較新
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 856024
3 856024
4 856024
5 856024
7 856024
10 856024
11 856024
12 856024
8 rows selected.
SQL> select file#,checkpoint_change# from v$datafile_header;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 850758
3 850758
4 850758
5 850758
7 850758