今天看见群里讨论flashback,我在虚机上尝试了一下。
先做了如下操作:
-
SQL> create restore point p1;
-
-
Restore point created.
-
-
SQL> create tablespace flash datafile \'/u01/app/oracle/oradata/gg1/flash01.dbf\' size 8m;
-
-
Tablespace created.
-
-
SQL> grant connect,resource to flash identified by flash;
-
-
Grant succeeded.
-
-
SQL> create table flash.emp as select * from scott.emp;
-
-
Table created.
-
-
SQL> create restore point p2;
-
-
Restore point created.
-
-
SQL> truncate table flash.emp;
-
-
Table truncated.
-
-
SQL> create restore point p3;
-
-
Restore point created.
之后在操作系统上删除/u01/app/oracle/oradata/gg1/flash01.dbf这个新增的文件
然后开始闪回
-
SQL> shutdown immediate
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
SQL> startup mount
-
ORACLE instance started.
-
-
Total System Global Area 661209088 bytes
-
Fixed Size 1338560 bytes
-
Variable Size 423625536 bytes
-
Database Buffers 230686720 bytes
-
Redo Buffers 5558272 bytes
-
-
Database mounted.
-
SQL>
-
-
SQL> flashback database to restore point p3;
-
-
Flashback complete.
在告警日志中发现如下信息:
-
Mon Mar 09 21:41:08 2015
-
flashback database to restore point p3
-
Mon Mar 09 21:41:08 2015
-
Errors in file /u01/app/oracle/diag/rdbms/gg1/gg1/trace/gg1_dbw0_7668.trc:
-
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
-
ORA-01110: data file 7: \'/u01/app/oracle/oradata/gg1/flash01.dbf\'
-
ORA-27037: unable to obtain file status
-
Linux Error: 2: No such file or directory
-
Additional information: 3
-
Flashback Restore Start
-
Deleted file /u01/app/oracle/oradata/gg1/flash01.dbf
-
Flashback: deleted datafile #7 in tablespace #7 from control file.
-
Flashback: dropped tablespace #7: \'FLASH\' from the control file.
-
Flashback Restore Complete
-
Flashback Media Recovery Start
-
Serial Media Recovery started
可见flashback,自动的帮助我们restore了datafile,真是意想不到啊。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30202921/viewspace-1684288/
,如需转载,请注明出处,否则将追究法律责任。