Wednesday, August 15, 2007

Performing a Flashback Table with SCN

1. Enable ROW MOVEMENT on table ACCOUNTS:

scott@TOY10G> alter table accounts enable row movement;
Table altered.

2. Retrieve the current SCN before you modify the table:

scott@TOY10G> select current_scn from v$database;
CURRENT_SCN
-----------
4280975

3. Update a value in the table so you can verify the change was eliminated after you
performed the Flashback Table operation to the SCN prior to the update:

scott@TOY10G> update accounts set balance=50000 where account_no = 10;
1 row updated.

scott@TOY10G> commit;
commit complete.

scott@TOY10G> select * from accounts where account_no=10;

ACCOUNT_NO BALANCE ACCOUNT_NAME
---------- ---------- --------------------
10 50000 6XNA6OSAT4OOR8I8


4. Perform the FLASHBACK TABLE command to recover the table to an SCN

scott@TOY10G> flashback table accounts to scn 4280975;
Flashback complete.

5. Query the table to verify the change was eliminated due to the Flashback Table to an

SCN prior to the existence of the change:

scott@TOY10G> select * from accounts where account_no=10;

ACCOUNT_NO BALANCE ACCOUNT_NAME
---------- ---------- --------------------
10 21627.9199 6XNA6OSAT4OOR8I8

No comments: