In Oracle12+ one can query a handy view called dba_mvref_stats to find all refreshes of a particular mview. I've bumped into the same task on Oracle 11g and I'm kinda stuck at the moment.
There's a similar question (History refresh of materialized view) but IMHO the answer doesn't responds the author's question as ALL_MVIEW_REFRESH_TIMES reflects refresh time of underlying table and keeps only latest refresh type.
What I'm looking for is an answer to question "Was there any COMPLETE refresh of a particular mview?". I create an mview on prebuilt table (which is empty) and want to run a COMPLETE refresh if it hasn't been run before or continue with a FAST refresh.
Maybe other options exist for me, so feel free to advise any.
EDIT: Question Materialized Views - Identifying the last refresh is about the last refresh event while I want to know the whole history of refreshes
Looks like the answer to the question "How does one get a HISTORY of all refreshes?" is "You can't" for Oracle 11g and "Yes, just query (dba/user)_mvref_stats view" for Oracle 12c+.
Also in case of Oracle 11g consider answering "What was the last refresh type/date?" instead of the question above. In this case you can check on all_mviews (and especially last_refresh_type).
Maybe it will help someone someday.
Related
Have a web service which connect to oracle database. On database side I have two database, from first I need select some information and in second database need to make some operations.
My question is about which is better to connect only second database and make replication by dbms or scheduler job from first db which release x times in a day to refresh data or make two data source on java side and after select some data from first database, connect second one to make some operations.
From my point of view, I'd access only the "second" database (in which you do those operations) and let it acquire data it needs from the "first" database via a database link.
That can be done directly, such as
select some_columns from db1_table#db_link where ...
or, if it turns out to be way too slow and difficult to tune, create a materialized view in the second database which would then be refreshed using one of available options (a scheduled refresh might be one of the choices).
As it is primarily opinion-based answer, I presume that you'll hear other options from someone else. Further discussion will raise the most appropriate solution to the top.
I'm looking at doing a data-fix and need to be able to prove that the data I have intended to change is the only data changed. (For example - that a trigger hasn't modified additional columns that I wasn't expecting)
I've been looking at Oracle's Flashback Query process, which would be great, except that this is not enabled on the database in question.
Since this check would be carried out prior to committing the transaction, Oracle must have the "before" information squirreled away somewhere, and I wondered if there is any way of accessing this undo information?
Otherwise, I would potentially have to make a temporary copy of each table and do a compare between the live table and the backup, which may also result in inconsistencies between the backup query time and the update transaction time.
While I'm expecting the answer "no", I'm hoping someone can point me in a better direction than that which I appear to be headed at present.
Thanks!
As I understand it, an Oracle readonly materialised view is similar to a real view, but it contains a full snapshot of the source data - stored in a similar way to a table. To update the snapshot, an Oracle command can be invoked to refresh the materialised view's contents from its source.
The question is, during a refresh, is the materialised view blocked from being read, or will the update be applied in an isolated fashion, allowing the old snapshot to still be read while the update is taking place?
Into Oracle writers don't block readers. Never. It's main advantage of versioning as is. Physically it looks same as if you update the table while somebody selects from it.
Btw, you can just try. Make MV with long refresh time and check if you can read it while refreshing.
For Oracle there are possible two ways how to cleanup the MV before refresing
truncate (DDL), DDL commits, so someone might see MV empty during refresh
delete(DML) is transactional, so users will either see old or new version of data.
As noted by #GriffeyDog see atomic_refresh option.
Could anyone please tell me if there is a possibility to create a hierarchical query in oracle 10g as a materialized view with REFRESH ON COMMIT?
I tried using CONNECT_BY but this doesn't work with REFRESH ON COMMIT.
Are there any other possibilities to get the view automatically refreshed when the underlying data changes?
Or may be there is an alternative to CONNECT_BY which works with REFRESH ON COMMIT?
Thanks in advance for any hints or help.
I really doubt that you'll be able to get this functionality. I think that the best you can hope for is to be able to define a materialized view that optimises the hierarchical query, for example by basing the MV on an underlying table that is actually index-organised or hash clustered on the parent_id column.
i am new to oracle.Already there is a store procedure which fetches data from many tables.Due to performance issue,i need to modify it.So i want to know about materialised view (since,i already searched it in net,but i am not able to understand it).can anyone explain the features of it?
Also,i am using TOAD for oracle.Can someone suggest me any materials(book,websites etc.) to learn?
I'll take the Toad portion - you can get a ton of great help online for free at ToadWorld.com. I have a 35 page free tutorial there as well link text
Materialized View is covered in the documentation (eg here).
They don't make anything magically run faster. They move the performance hit (eg refresh the view at midnight and your procedure may run faster at 9am) but possibly at the expense of being 'up-to-date'. Or you could have REFRESH ON COMMIT MVs which can be more up to date, but maybe at the expense of concurrency and are also 'time shifting' work to when inserts/updates are done rather than queries.
MVs would be a long way down the list of things I'd consider for fixing a problem in a specific stored procedure.