restore point:
inlcude normal restore point and guaranteed restore point
normal restore points and guaranteed restore points are stored in control file;
normal restore point:
you can consider it as an alias of a timestamp or a scn。
The database can retain at least 2048 normal restore points.
Normal restore points are retained in the database for at least the number of days specified for the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter. The default value of that parameter is 7 days.
If you specify neither PRESERVE nor GUARANTEE FLASHBACK DATABASE, then the resulting restore point enables you to flash the database back to a restore point within the time period determined by the DB_FLASHBACK_RETENTION_TARGET initialization parameter.
The database automatically manages such restore points. When the maximum number of restore points is reached, according to the rules described in restore_point above, the database automatically drops the oldest restore point.
Under some circumstances the restore points will be retained in the RMAN recovery catalog for use in restoring long-term backups. You can explicitly drop a restore point using the DROP RESTORE POINT statement.
guaranteed restore point:
Guaranteed restore points are retained in the database until explicitly dropped by the user.
A guaranteed restore point enables you to flash the database back deterministically to the restore point regardless of the DB_FLASHBACK_RETENTION_TARGET initialization parameter setting. The guaranteed ability to flash back depends on sufficient space being available in the fast recovery area.
Guaranteed restore points guarantee only that the database will maintain enough flashback logs to flashback the database to the guaranteed restore point. It does not guarantee that the database will have enough undo to flashback any table to the same restore point.
Guaranteed restore points are always preserved. They must be dropped explicitly by the user using the DROP RESTORE POINT statement. They do not age out. Guaranteed restore points can use considerable space in the fast recovery area. Therefore, Oracle recommends that you create guaranteed restore points only after careful consideration.
Guaranteed restore point + Flashback Database on + flashback log = rewind any scn from the Guaranteed restore point to now;
--------Noarchivelog模式+未开启flashback database:
可以创建normal restore point,但不能创建guaranteed restore point
不能使用flashback database,因为flashback database要求开启Flashback database logging
SQL> flashback database to restore point normal_point;
flashback database to restore point normal_point
*
ERROR at line 1:
ORA-38726: Flashback database logging is not on.
开启flashback database 要求必须开启Archivelog
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38707: Media recovery is not enabled.
--------开启Archivelog+未开启flashback database:
可以创建normal restore point和guaranteed restore point,但是只能用guaranteed restore point进行flashback database操作,且只能恢复到guaranteed restore point那个节点
SQL> create restore point normal_point;
Restore point created.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
SQL> create restore point guarantee_point1 guarantee flashback database;
Restore point created.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
RESTORE POINT ONLY
SQL> flashback database to restore point NORMAL_POINT;
flashback database to restore point NORMAL_POINT
*
ERROR at line 1:
ORA-38782: cannot flashback database to non-guaranteed restore point
'NORMAL_POINT'
SQL> flashback database to restore point GUARANTEE_POINT1;
flashback database to restore point GUARANTEE_POINT1
*
ERROR at line 1:
ORA-38757: Database must be mounted and not open to FLASHBACK.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
SQL> flashback database to restore point GUARANTEE_POINT1;
Flashback complete.
SQL> alter database open resetlogs;
Database altered.
--------开启Archivelog+开启flashback database:
guranteed restore point 可以恢复到restore point 后的任何时间点
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
RESTORE POINT ONLY
SQL> alter database flashback on;
Database altered.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
相关参数:
CONTROL_FILE_RECORD_KEEP_TIME----normal restore point在控制文件中的存储周期受其影响
DB_FLASHBACK_RETENTION_TARGET----normal restore point能恢复的时间段(单位:分钟)
db_recovery_file_dest---------闪回区路径
db_recovery_file_dest_size---------闪回区size
相关视图:
V$FLASHBACK_DATABASE_LOG----------查看闪回信息
v$restore_point-------查restore point信息
(https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_6011.htm#SQLRF20001)