Query materialized view refresh timestamp

Unlike my lengthy posts, this is really a quick one.

Alright, so how do you get to know when your materialized view got refreshed? Well, no biggies. There are bunch of dictionary views who capture refresh date but none of them give you timestamp. For fast refresh, you can work with SCN or timestamp based MView logs but for complete refresh M-views, this can be tricky and here is a quick easy solution to retrieve timestamp information.

You can query ALL_MVIEW_ANALYSIS dictionary view that captures System change number (SCN) of the last refresh operation (i.e start refresh time). Use SCN_TO_TIMESTAMP function to translate SCN into timestamp. Here is the query –

SELECT owner,
mview_name,
last_refresh_scn,
SCN_TO_TIMESTAMP (last_refresh_scn) refresh_timestamp
FROM all_mview_analysis
WHERE mview_name = <>;

Try it yourself. I recommend this dictionary table as it also lets you know the time taken in fast or full refresh (FULLREFRESHTIM/INCREFRESHTIM). Don’t miss this nice article “How long did Oracle materialized view refresh run?” by Ittichai C.

Advertisements