Thursday, November 3, 2011

Oracle High Availability Architecture: Flashback Transaction

In the name of Allah, Most Gracious, Most Merciful.

In this article i will describe "Flashback Transaction" feature of Oracle 11g. Flashback Transaction is a part of Oracle High Availability Architecture. One a transaction is committed it cannot be rolled back. what if a user inserted some dummy rows and committed them accidentally and don't know the information inserted? He only remembers the approximate time of transaction and affected table. To remove these inserted and committed rows we will use flashback transaction feature of Oracle 11g.
Supplemental Logs should be added to use this feature. To do so run following commands from sys user.

$ sqlplus / as sysdba
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;

Figure - 1

Now create a table and insert some rows in it and commit them to make it a transaction.

$ sqlplus scott/*****
SQL> create table myflashbacktable (acol number, bcol varchar2(50));
SQL> insert into myflashbacktable values (&acol, '&bcol');
SQL> commit;

Figure - 2

Now through database control or grid control search and flashback this transaction. Under "Availability" tab click the "View and Manager Transactions" link

Figure - 3

Provide the start time and end time parameters to search the transaction and provide the table and DB user parameters to narrow down the search. 

Figure - 4

Log miner is searching the transaction on provided table between start and end time parameters.

Figure - 5

Transactions are listed. select the transaction you want to flashback.


Figure - 6

Transaction details are listed click the "Flashback Transaction" button to flashback this transaction.

Figure - 7

Click Yes on confirmation screen.

Figure - 8

Information generation for flashback is in progress.

Figure - 9

Click "Finish" to flashback the transaction.

Figure - 10

Transaction is flash backed. Open the sqlplus and confirm that all three rows inserted are now removed.

Figure - 11


Insha-Allah this will help and serve the purpose. For any corrections and improvements please suggest.