[oracle@rhel5 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 30 22:56:46 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
查看数据库能闪回到的最早的scn,如果数据库没有开闪回功能是没有记录返回的。
SQL> select oldest_flashback_scn from v$flashback_database_log;
no rows selected
查看数据库是否开闪回
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
数据库open状态尝试开启数据库的闪回功能,返回报错信息说明需要在mount状态下来操作。
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38759: Database must be mounted by only one instance and not open.
关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
打开数据库到mount状态
SQL> startup mount
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 1218412 bytes
Variable Size 83888276 bytes
Database Buffers 96468992 bytes
Redo Buffers 2973696 bytes
Database mounted.
数据库在mount状态下再次尝试开启数据库的闪回功能,又返回错误信息说明数据库在非归档状态下不支持数据库的闪回。
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.
开归档
SQL> alter database archivelog;
Database altered.
开闪回成功
SQL> alter database flashback on;
Database altered.
打开数据库
SQL> alter database open;
Database altered.
开启归档,默认的归档目录:USE_DB_RECOVERY_FILE_DEST ,与9i不同10g开启归档很要简单一些。以后可以自行修改归档目录的位置,在此暂时保留默认。
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 59
Next log sequence to archive 61
Current log sequence 61
检验数据库闪回是否开启
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
查看闪回区信息,默认安装大小为2G,根据数据库的具体情况作修改。
SQL> show parameter recover_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 20G
数据库可以恢复到多少分钟以前,默认1440分钟(一天)
SQL> show parameter flash
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440
查看数据库能恢复到最早的scn,和最早的时间
SQL> select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TIME
-------------------- ---------------------
1021372 20101130 23:07:18
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23009281/viewspace-758017/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23009281/viewspace-758017/