Flashback Database is to rewind the database to a target time, its usually much faster than a RESTORE operation followed by point-in-time recovery because no data files are restored.
For Enable Flasback in Database
Database should be in Archive Mode
show parameter db_recovery_file_dest;
alter system set db_recovery_file_dest = '/data/fastrecoveryarea';
alter system set db_recovery_file_dest_size=300g;
select flashback_on from v$database;
alter database flashback on;
select flashback_on from v$database;
Flash back Retention
How far back one can flashback a database depends on how much flashback data Oracle has kept in the fast recovery area
alter system set DB_FLASHBACK_RETENTION_TARGET = 1440;
Check SCN from Database
SELECT current_scn, TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') FROM v$database;
Check Usage of Flash Recovery Area
select * from v$flash_recovery_area_usage;
Check Available in Recovery Destination Area
select name, floor(space_limit / 1024 / 1024/1024) "Size GB", ceil(space_used / 1024 / 1024/1024) "Used GB" from v$recovery_file_dest order by name;
Check Transaction Query Inside Flash Logs or what exactly store in flashback
SELECT operation, undo_sql, table_name,COMMIT_TIMESTAMP
FROM flashback_transaction_query;
SELECT table_name, count(*)
FROM flashback_transaction_query group by table_name;
Disable Flashback Database
alter database flashback off;
Flashback database to Specific Time
sqlplus / as sysdba
shutdown immediate
startup mount exclusive
flashback database to timestamp sysdate-(1/24/12);
alter database open resetlogs;
More Flashback Database Options
flashback database to timestamp {my_date};
flashback database to before timestamp {my_date};
flashback database to scn {my_scn};
flashback database to before scn {my_scn};
Flashback Database to Specific Restore Point
flashback database to restore point before_changes;
Enable Flashback Table
CREATE TABLE flashback_table_test (
id NUMBER(10)
);
ALTER TABLE flashback_table_test ENABLE ROW MOVEMENT;
Flashback Tables
FLASHBACK TABLE flashback_table_test TO SCN 715315;
FLASHBACK TABLE flashback_table_test TO TIMESTAMP TO_TIMESTAMP('2004-03-03 10:00:00', 'YYYY-MM-DD HH:MI:SS');
Flashback Query for Table Data
SELECT COUNT(*)
FROM flashback_query_test AS OF TIMESTAMP TO_TIMESTAMP('2004-03-29 13:34:12', 'YYYY-MM-DD HH24:MI:SS');
SELECT COUNT(*)
FROM flashback_query_test AS OF SCN 722452;
Emergency Cleanup Flashback Logs
SELECT operation, undo_sql, table_name,COMMIT_TIMESTAMP FROM flashback_transaction_query;
alter database flashback off;
alter database flashback on;
