Oracle 10g has built in audit management to track changes to the table. Oracle tracks the values by using pseudo-columns versions_starttime,versions_endtime,
versions_xid ,versions_operation,versions_startscn and versions_endscn
versions_xid: Column identifies transaction that modified the table.You can query FLASHBACK_TRANSACTION_QUERY table for this value to get the history of the transaction and the corresponding UNDOSQL
Example
Create table testing (col1 varchar2(10), col2 int);
Insert into testing values ( 'A',10);
Insert into testing values ( 'B',20);
Commit;
Update testing set col2 = 202 where col1 = 'B';
Commit;
Delete from testing ;
Commit;
sELECT * from testing; -->0 Records
Now to get the history
Select testing.*,versions_starttime,versions_endtime,versions_operation,
versions_startscn,versions_endscn,versions_xid
from testing
versions between timestamp minvalue and maxvalue
To get details of the transaction and the undo sql fo the transaction,
Select * from
flashback_transaction_query
where xid ='050054001FAF0000'
IMPORTANT
This query pulls data from undo segments, so you cannot get a complete history of the transaction.As long as you have the data in UNDO_SEGMENTS, You can always query history of any tables.
No comments:
Post a Comment