- SQL> select scn,to_char(TIMESTAMP,'yyyy-mm-dd hh24:mi:ss') TIMESTAMP,SQL_REDO,SQL_UNDO from v$logmnr_contents where table_name = 'EMP';
- SCN TIMESTAMP SQL_REDO SQL_UNDO
- ---------- -------------------- -------------------- --------------------
- 2507301 2017-04-10 22:54:49 drop table emp purge
复制代码
到此为止,我们已经挖掘成功,找到scn和时间点
注意:如果用时间点恢复的时候要减1秒
最后关闭数据挖掘
SQL> exec dbms_logmnr.end_logmnr;
PL/SQL procedure successfully completed.
4. 不完全恢复
复制代码
- RMAN> shutdown immediate;
- using target database control file instead of recovery catalog
- database closed
- database dismounted
- Oracle instance shut down
- #先关闭数据库
- RMAN> startup mount;
- connected to target database (not started)
- Oracle instance started
- database mounted
- Total System Global Area 584568832 bytes
- Fixed Size 2230552 bytes
- Variable Size 444597992 bytes
- Database Buffers 130023424 bytes
- Redo Buffers 7716864 bytes
- #启动倒mount状态下
- RMAN> run{
- 2> set until scn 2507301;
- 3> restore database;
- 4> recover database;
- 5> alter database open resetlogs;
- 6> }
- executing command: SET until clause
- Starting restore at 10-APR-17
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=137 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 /u01/oracle/oradata/orcl/system01.dbf
- channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/oradata/orcl/sysaux01.dbf
- channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/orcl/users01.dbf
- channel ORA_DISK_1: restoring datafile 00005 to /u01/oracle/oradata/orcl/user02.dbf
- channel ORA_DISK_1: restoring datafile 00006 to /u01/oracle/oradata/orcl/tmpspace0327
- channel ORA_DISK_1: restoring datafile 00007 to /u01/oracle/oradata/orcl/undotbs02.dbf
- channel ORA_DISK_1: restoring datafile 00008 to /u01/oracle/oradata/orcl/example.dbf
- channel ORA_DISK_1: reading from backup piece /tmp/0us1cc3q_1_1
- channel ORA_DISK_1: piece handle=/tmp/0us1cc3q_1_1 tag=TAG20170410T225138
- channel ORA_DISK_1: restored backup piece 1
- channel ORA_DISK_1: restore complete, elapsed time: 00:01:15
- Finished restore at 10-APR-17
- Starting recover at 10-APR-17
- using channel ORA_DISK_1
- starting media recovery
- media recovery complete, elapsed time: 00:00:01
- Finished recover at 10-APR-17
- database opened
- # 用上面run{}脚本进行恢复,restore,recover,open resetlogs;
- # 成功
5. 验证
复制代码
- <blockquote>SQL> desc emp;
- Name Null? Type
- ----------------------------------------- -------- ----------------------------
- EMPNO NOT NULL NUMBER(4)
- ENAME VARCHAR2(10)
- JOB VARCHAR2(9)
- MGR NUMBER(4)
- HIREDATE DATE
- SAL NUMBER(7,2)
- COMM NUMBER(7,2)
- DEPTNO NUMBER(2)
- SQL> select count(*) from emp;
- COUNT(*)
- ----------
- # 被删除的emp表恢复成功
如果有对软件测试感兴趣的小伙伴可以了解更多:点击进群https://jq.qq.com/?_wv=1027&k=9MuyI1n