1.修改闪回区大小,路径,保留时间
SQL> show parameter db_recovery_file_dest
SQL> show parameter db_flashback_retention_target
SQL> alter system set db_recovery_file_dest_size=20G scope=both;
System altered.
SQL> alter system set db_recovery_file_dest='/arch/flashback' scope=both;
System altered.
SQL> alter system set db_flashback_retention_target=4320 scope=both; --单位分钟 4320=3天
System altered.
2.开启数据库闪回,需要停库启动到mount
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 584568832 bytes
Fixed Size 2255432 bytes
Variable Size 226493880 bytes
Database Buffers 348127232 bytes
Redo Buffers 7692288 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
3.创建闪回点
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
YES
SQL> create restore point BEFORE_UPDATE guarantee flashback database;
Restore point created.
SQL> set line 200 pages 1000
SQL> col time for a35
SQL> col RESTORE_POINT_TIME for a30
SQL> col NAME for a30
SQL> select * from v$restore_point;
SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME RESTORE_POINT_TIME PRE NAME
---------- --------------------- --- ------------ ----------------------------------- ------------------------------ --- ------------------------------
1117669 2 YES 52428800 23-SEP-22 08.18.37.000000000 PM YES BEFORE_UPDATE
4.删除闪回点,关闭闪回,可以在线执行
SQL> drop restore point before_update;
Restore point dropped.
SQL> select * from v$restore_point;
no rows selected
SQL> alter database flashback off;
Database altered.
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
5.执行闪回数据库命令
SQL> startup mount
ORACLE instance started.
Database mounted.
SQL> select * from v$restore_point;
SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME RESTORE_POINT_TIME PRE NAME
---------- --------------------- --- ------------ ----------------------------------- ------------------------------ --- ------------------------------
1117848 2 YES 52428800 23-SEP-22 08.20.59.000000000 PM YES BEFORE_UPDATE
SQL> flashback database to restore point BEFORE_UPDATE;
Flashback complete.
SQL> alter database open resetlogs;
Database altered.
SQL> drop restore point BEFORE_UPDATE;
Restore point dropped.
SQL> alter database flashback off;
Database altered.