3. Oracle Database Flashback
Oracle Database Flashback Technologies are a unique
and rich set of data recovery solutions that enable
reversing human errors by selectively and efficiently
undoing the effects of a mistake.
Before Flashback, it might take minutes to damage a
database but hours to recover it.
Oracle Flashback Technology is a group of Oracle
Database features that that let you view past states of
database objects or to return database objects to a
previous state without using point-in-time media
recovery.
5. What is Flashback Technology?
Oracle Flashback Technology provides a set of features
available on 9i or higher version that support viewing
and rewinding data back and forth in time to recover
from Logical Corruptions while the database is online.
To view the past state of database objects.
To return a database object to a previous state without
point-in-time media recovery.
Uses automatic undo management.
Flashback technology basically handle the errors
produced by human
6. Flashback Technology?
Data loss and Recovery
Human error
Logical data corruption
Time consuming recovery
Oracle flashback technology reduced recovery
time from hours to minutes
Example
8. Why?
Execute queries that return past data(history’s data)
Execute queries that return metadata that shows a
detailed history of changes to the database
Recover data to a previous point in time
Automatically track and archive transactional
Changes data
Roll back a transaction and its dependent
transactions while the database remains online
Note: we need to know what was the data in history, do
why we need to go back to historical data.
10. Pre-requisites:
Database Must be in ARCHIVE LOG mode
Execute permission on DBMS_FLASHBACKpackage
SELECT ANY TRANSACTION privilege
FLASHBACK ANY TRANSACTION privilege
CREATE TABLE privilege
Enable SUPPLEMENTAL LOG DAT A
Set FLASHBACK_ON
12. 1. Flashback query:
To view the snapshot of records all given time all
command executed between time.
Oracle Flashback Query feature lets you specify a target
time and then run queries against your database, viewing
results as they would have appeared at that time.
query any data at some point-in-time in the past. This
powerful feature can be used to view and logically
reconstruct corrupted data that may have been deleted or
changed inadvertently.
retrieves data as it existed at some time in the past.
E.g:
select count(*) from COURSE as of timestamp sysdate -
5/(24*60);
13. 2. Flashback version Query
To see the transaction which has been perform on a
table.
Oracle Flashback Version Query lets you view all the
versions of all the rows that ever existed in one or more
tables in a specified time interval.
E.g:
Select versions_starttime, versions_endtime,
versions_xid, from the COURSE versions between
timestamp minvalue and maxvalue;
14. 3. Flashback transaction query:
Used to recover the transaction as per “xid” number
which we have got through previous version query.
Oracle Flashback Transaction Query lets you view
changes made by a single transaction, or by all the
transactions during a period of time.
see all the changes made by a specific transaction,
useful when an erroneous transaction changed data in
multiple rows or tables.
E.g:
Select undo_sql from flashback_transation_query
where xid= “ xid_no.”;
15. 4. Flashback table
Oracle Flashback Table returns a table to its state at a
previous point in time.
easily recover tables to a specific point-in-time, useful
when a logical corruption is limited to one or a set of
tables instead of the entire database.
E.g:
FLASHBACK TABLE ftest TO TIMESTAMP
TO_TIMESTAMP('05-02-2008 10:22:45','DD-MM-
YYYY HH:MI:SS');
16. 5.Flashback Drop:
Recover an accidentally dropped table. It restores the dropped
table, and all of its indexes, constraints, and triggers, from the
Recycle Bin (a logical container of all dropped objects).
reverses the effects of a DROP TABLE statement.
E.g:
select OBJECT_NAME,ORIGINAL_NAME from user_recyclebin;
show recyclebin;
SELECT * FROM "BIN$RWou3ZujSqXgQBQKHZhmkg==$0";
FLASHBACK TABLE fsbtest.ftest_drop TO BEFORE DROP;
FLASHBACK TABLE "BIN$RWou3ZujSqXgQBQKHZhmkg==$0"
TO BEFORE DROP RENAME TO fsbtest.ftest1;
17. 6. Flashback Database
Flashback Database provides a more efficient
alternative to database point-in-time recovery.
restore the entire database to a specific point-in-time,
using Oracle-optimized flashback logs, rather than via
backups and forward recovery.
E.g:
select NAME,FLASHBACK_ON from v$database;
SELECT CURRENT_SCN FROM V$DATABASE;