If a data file has changed status between the current SCN and the target SCN of the flashback, then the FLASHBACK DATABASE command behaves differently depending on the nature of the status change.
今天跟群里的人讨论flashback,发现flashback之后,如果想回到当前状态,那么用flashback会比recover更方便
我做了如下实验
1、先准备环境
1)创建第一个restore point叫做p1
2)为users表空间添加数据文件/u01/app/oracle/oradata/gg1/users02.dbf
3)
创建第二个restore point叫做p2
2、开始用闪回了
-
SQL> flashback database to restore point p1;
-
-
Flashback complete.
参加官方文档:
After FLASHBACK DATABASE completes, you may want to open the database read-only and run queries to ensure that you achieved the intended result.
If you are not satisfied, then you can use RECOVER DATABASE to recover the database to its state when you started the flashback. You can then rerun FLASHBACK DATABASE.
我recover了database
-
SQL> recover database;
-
ORA-00283: recovery session canceled due to errors
-
ORA-01244: unnamed datafile(s) added to control file by media recovery
-
ORA-01110: data file 6: \'/u01/app/oracle/oradata/gg1/users02.dbf\'
参见官方文档:
ORA-01244: unnamed datafile(s) added to control file by media recovery
Cause: Media recovery with a backup control file or a control file that was rebuilt, encountered the creation of a datafile that was not in the control file. An entry has been added to the control file for the new datafiles, but with the file name UNNAMEDnnnn, where nnnn is the file number. Attached errors describe the file names that were originally used to create the files.
控制文件,变成一个老的控制文件了,已经不认识新的文件了
参见官方文档:
Action: Rename the files to valid file names and resume recovery. If necessary the command ALTER DATABASE CREATE DATAFILE may be used to create a file suitable for recovery and do the rename. If the file is not going to be recovered then take it offline with the FOR DROP option.
可以通过创建数据文件解决
-
SQL> alter database create datafile 6 as \'/u01/app/oracle/oradata/gg1/users02.dbf\';
-
-
Database altered.
-
-
SQL> recover database;
-
Media recovery complete.
recover回来了。
3.现在换一个方法,恢复回来,因为有另外一个restore point叫做p2
-
SQL> flashback database to restore point p1;
-
-
Flashback complete.
-
SQL> flashback database to restore point p2;
-
-
Flashback complete.
-
-
SQL> recover database;
-
Media recovery complete.
由此可见,使用闪回,是比用recover方便的,因为flashback会自动 帮我们维护好controlfile。
所以执行第一条闪回之前,先记一下当前的scn,那么回到现在会更加的方便。
如果你闪回到p1这个restore point,从p1到现在,一同加了1000个数据文件,用recover是不是很无语啊,哈哈!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30202921/viewspace-1684351/
,如需转载,请注明出处,否则将追究法律责任。