Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Tirambad.

Asked: June 19, 2019 - 8:27 pm UTC

Last updated: June 20, 2019 - 10:41 am UTC

Version: 11.2.0.4.0

Viewed 1000+ times

You Asked

In 12c and above, we can get the information about who changed the record using:

DBMS_FLASHBACK_ARCHIVE.get_sys_context(versions_xid, 'USERENV','SESSION_USER')


There is no such feature of getting sys context in 11g flashback data archive. One way of achieving this would be to get it from the view FLASHBACK_TRANSACTION_QUERY. My knowledge is that the view FLASHBACK_TRANSACTION_QUERY is generated off of UNDO tablespaces whereas flashback data archives are based on user-defined tablespaces with defined retention years.

In conclusion, I didn't find any metadata source while using flashback data archive from where I can pull the info of the user who modified the record. Is there a way around this in 11g?

and Chris said...

I'm not aware of a function in 11g that emulates this.

But if you have auditing enabled on the table, that stores the transaction ID. So you can join the versions_xid to the audit:

create flashback archive fba 
  tablespace users retention 1 month;
  
create table t (
  c1 int
) flashback archive fba;

audit select, insert, update, delete on t;

insert into t values ( 1 );
commit;
update t
set    c1 = 2;
commit;
delete t;
commit;

select t.*, versions_xid, versions_operation, username
from   chris.t versions between scn minvalue and maxvalue t
left join dba_audit_trail a
on     a.transactionid = versions_xid;

C1   VERSIONS_XID       VERSIONS_OPERATION   USERNAME   
    2 0F001300CD130000    D                     CHRIS       
    2 1000140075150000    U                     CHRIS       
    1 15000100C9140000    I                     CHRIS  


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Backup/Recovery

Check out the complete guide to all of the Backup & Recovery techniques in the Oracle Database.