Skip to Main Content
  • Questions
  • about materialized view log mlog issues

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, java-jack.

Asked: September 27, 2016 - 7:12 am UTC

Last updated: September 27, 2016 - 9:18 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi team,
I want to get some field values from some tables.If field values of tables changed. it must be captured.don't use trigger。
for example:
table:A fields:a1(primary key), a2,a3
table: B fields:b1(primary key),b2,b3
If table A field a2 was changed,It will be captured.If table A field was changed.I will not be captured.

I consider that use materialized view log mlog .but materialized view log mlog stored all changed records.
select * from mlog$_tw_tower_test;
TOWER_ID LONGITUDE STATION_ID MODIFY_TIME SNAPTIME$$ DMLTYPE$$ OLD_NEW$$ CHANGE_VECTOR$$ XID$$
005088430200000048918753 1112.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U U 0000000000 2814749767128640.00
005088430200000048918753 1112.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U N 0000000000 2814749767128640.00
005088430200000048918753 1112.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U U 0800000000 3096357887858220.00
005088430200000048918753 1112.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U N 0800000000 3096357887858220.00
005088430200000048918753 1112.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U O 0002000000 1688957234458800.00
005088430200000048918753 555.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U N 0002000000 1688957234458800.00

I just want save latest record and SNAPTIME$$ how to change update?
005088430200000048918753 555.0000000000 005002010200000027282653 2016/11/22 11:37:46 4000/1/1 U N 0002000000 1688957234458800.00


please help me.
Thanks in advance.

and Chris said...

You're trying to use materialized view logs for your audit?!

Don't do this!

Mview logs are for managing fast refreshes of materialized views. Not your audit!

If you want to capture changes to your data, but can't use triggers you could look into:

- Updating your application to write the audit at the same time as the real change. Clearly this could be a lot of work
- Using flashback data archive to store the history. Once you enable this, Oracle will keep track of all the changes for you.

Note this used to be part of a separately licensed option (Total Recall). It's now free starting in 11.2.0.4.

For further details see:

http://www.oracle.com/technetwork/issue-archive/2008/08-jul/flashback-data-archive-whitepaper-129145.pdf
http://docs.oracle.com/database/121/ADFNS/adfns_flashback.htm#ADFNS01011
https://oracle-base.com/articles/12c/flashback-data-archive-fda-enhancements-12cr1

Rating

  (1 rating)

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

Comments

java-jack jack, September 27, 2016 - 9:43 am UTC

thanks

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library