select log_mode from v$database; 1- 确定数据库开启归档
LOG_MODE
------------
ARCHIVELOG
SQL> alter system set db_recovery_file_dest='/home/oracle/flash_recovery_area';
alter system set db_recovery_file_dest='/home/oracle/flash_recovery_area'
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-19802: cannot use DB_RECOVERY_FILE_DEST without DB_RECOVERY_FILE_DEST_SIZE
2-创建闪回恢复区(先配置大小在配置目录)
SQL> show parameter db_reco
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
SQL> alter system set db_recovery_file_dest_size=8g;
System altered.
SQL> alter system set db_recovery_file_dest='/home/oracle/flash_recovery_area';
System altered.
3-设置闪回保留时间
SQL> alter system set db_flashback_retention_target=240; 保存时间以分钟为单位,默认是一天
System altered.
4-停库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 2019320 bytes
Variable Size 96469000 bytes
Database Buffers 67108864 bytes
Redo Buffers 2174976 bytes
Database mounted.
5-启动闪回日志记录
SQL> alter database flashback on;Database altered.
6-打开数据库
SQL> alter database open;
Database altered.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES