restore point分为normal restorepoint 和 guaranteed restore point两种。normal restore point 仅仅作为scn和时间点的别名使用,无其他用途,占用的控制文件空间也非常小,通常无需特别关注。控制文件会自动清除normal restore point 的信息,清除时遵循如下规则:
(1) The most recent 2048 restorepoints are always kept in the control file, regardless of their age.
(2) Any restore point more recentthan the value of CONTROL_FILE_RECORD_KEEP_TIME is retained,regardless of how many restore points are defined.
guaranteed restore point 同样作为scn和时间点的别名使用,但是控制文件不会自动清除guaranteed restore point ,必须通过手工才可以删除。另外,在不开启flashback database的情况下,guaranteed restore point仍然可以使我们使用flashback database技术,只是此时我们只可以闪回到guaranteed restore point指定的时间点。此时,仍然会生出闪回日志,只是闪回日志中仅仅存储guaranteed restore point时间点之后数据块第一次发生改变时的“before image”。
我们知道,flashback database 与nologging的支持不太好,可能会造成坏块(间歇性的保持数据块前镜像,需要使用redo恢复数据)。但是在没有启用flashback database情况下的guaranteed restore point可以很好的支持nologging,因为此时不需要使用redo日志数据。在启用flashback database log的情况下,如果创建guaranteed restore point,可以保证在guaranteed restore point到当前时间的任意时间点数据库都是可以闪回的。If you enableFlashback Database and define one or more guaranteed restore points, then thedatabase performs normal flashback logging.
flashback database 可以针对某表空间关闭,如:
SQL> alter database flashback on;
Database altered.
SQL> alter tablespace users flashback off;
Tablespace altered.
SQL> create table test1 tablespace users as select * from test;
Table created.
SQL> insert into test values(1,1);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test1 select * from test;
1 row created.
SQL> commit;
Commit complete.
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1188094
SQL> insert into test select * from test;
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test1 select * from test1;
1 row created.
SQL> commit;
Commit complete.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 267227136 bytes
Fixed Size 2227504 bytes
Variable Size 192938704 bytes
Database Buffers 67108864 bytes
Redo Buffers 4952064 bytes
Database mounted.
SQL> flashback database to scn
2 1188094;
flashback database to scn
*
ERROR at line 1:
ORA-38753: Cannot flashback data file 4; no flashback log data.
ORA-01110: data file 4: '/u01/app/oraele/oradata/orcl/users01.dbf'
SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01109: database not open
SQL> alter tablespace users read only;
alter tablespace users read only
*
ERROR at line 1:
ORA-01109: database not open
SQL> alter database open;
Database altered.
SQL> alter tablespace users offline;
Tablespace altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 267227136 bytes
Fixed Size 2227504 bytes
Variable Size 192938704 bytes
Database Buffers 67108864 bytes
Redo Buffers 4952064 bytes
Database mounted.
SQL> flashback database to scn 1188094;
Flashback complete.
SQL> alter database open resetlogs;
Database altered.
SQL> alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-01190: control file or data file 4 is from before the last RESETLOGS
ORA-01110: data file 4: '/u01/app/oraele/oradata