##开启flasbback
SQL> alter system set db_recovery_file_dest_size=80g scope=spfile;
SQL> alter system set db_recovery_file_dest_size=80g scope=spfile;
设置闪回区位置:
SQL> alter system set db_recovery_file_dest='/workdb/account_flashback_area' scope=spfile;
设置闪回目标为5天,以分钟为单位,每天为1440分钟:
SQL> alter system set db_flashback_retention_target=7200 scope=spfile;
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1056411648 bytes
Fixed Size 2257584 bytes
Variable Size 612371792 bytes
Database Buffers 436207616 bytes
Redo Buffers 5574656 bytes
Database mounted.
SQL> alter database flashback on; #关闭alter database flashback off;
Database altered.
SQL> alter database open;
##查询当前的scn号
SQL> select CURRENT_SCN from v$database;
CURRENT_SCN
-----------
724633
##查询当前的log sequence号
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCH1
Oldest online log sequence 30
Next log sequence to archive 32
Current log sequence 32
####通过flashback恢复数据库
startup mount
##恢复到指定的时间点
flashback database to timestamp(to_date('2010-01-01 20:00:00','YYYY-MM-DD HH24:MI:SS'));
flashback database to timestamp(sysdate-1/24); ##恢复到一小时前
##恢复到指定的SCN
flashback database to scn ********;
##恢复到某个log sequence
flashback database to sequence=**** thread=1;
alter database open resetlogs;
####通过flashback恢复表
##通过flashback恢复被删除的表,如果cyclebin已经被开启
flashback table <table_name> to before drop [rename to <net_name>];
##回退到一小时前
flashback table <table_name> to timestamp(system-1/24);
##多表同时回退到指定的时间点
flashback table <table_name,table_name> to timestamp(system-1/24/60); ##回退到1分钟前
##回退到指定的scn
flashback table <table_name> to scn ******;
##回退是启动出发起
flashback table <table_name> to scn ****** enable triggers;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28572479/viewspace-2144620/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28572479/viewspace-2144620/