Flashback DROP
flashback table text_xinzi to before drop;
flashback table a to before drop rename to B;
Flashback Query恢复之前的数据
--as of timestamp
select * from A as of timestamp sysdate-5/1440;
insert into A select * from A as of timestamp to_timestamp('2009-10-15 19:04:16','YYYY-MM-DD hh24:mi:ss');
--as of scn
select current_scn from v$database;
insert into A select * from A as of scn 1095782;
Flashback Table现对数据的回退
flashback Table也是使用undo tablespace的内容来实现对数据的回退。
注意:如果想要对表进行flashback,必须允许表的row movement.
alter table table_name row movement;
要查看某表是否启用row movement,可以到user_tables 中查询(或all_tables,dba_tables),
select row_movement from user_tables where table_name='eic_code';
要启用或禁止某表row movement,可以通过下列语句:
--启用ALTER TABLE table_name ENABLE ROW MOVEMENT;
--禁止ALTER TABLE table_name DISABLE ROW MOVEMENT;
select current_scn from v$database;
alter table c enable row movement;
flashback table c to scn 1103864;
flashback table c to timestamp to_timestamp('2009-10-15 21:17:47','yyyy-mm-dd hh24:mi:ss');
flashback table 命令支持同时操作多个表,表名中间以逗号分隔即可,如果你执行一条flashback table命令时同时指定了多个表,单个flashback table 在同一个事务中.
Flashback Database
启用flash recovery area:
alter system set db_recovery_file_dest_size=20g scope=both;
alter system set db_recovery_file_dest='/dba/fb' scope=both;
alter database flashback on;
flashback database to timestamp to_timestamp('09-10-14 14:37:05','yy-mm-dd hh24:mi:ss');
flashback database to scn 947921;