Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Disable Materialized View Refresh

Anyone have the syntax to disable the refresh of a materialized view in Oracle? I struggle with the Oracle documentation and I'm not finding an online example.

I understand it starts something like: ALTER MATERIALIZED VIEW view_name ...

like image 253
Jeff Avatar asked Mar 01 '16 18:03

Jeff


People also ask

How do I stop a materialized view from refreshing?

A materialized view created with the automatic refresh can not be alter to stop refreshing. In order to disable that you must break the dbms_job that was created in order to refresh the view. Mview are local copies of data located remotely, or are used to create summary tables based on aggregations of a table's data.

Are materialized views automatically refreshed?

Unlike indexes, materialized views are not automatically updated with every data change. They must explicitly be refreshed, either on every commit, on a periodically time schedule or – typically in data warehouses – at the end of an ETL job.

How do you check if materialized view is refreshed or not?

You can also use v$mvrefresh dynamic performance view to know which MV is being refresh.

Can we truncate materialized view in Oracle?

When you truncate a table, Oracle Database automatically removes all data in the table's indexes and any materialized view direct-path INSERT information held in association with the table. This information is independent of any materialized view log.


1 Answers

If it is currently set to refresh on commit, you can change it to refresh on demand, which means you need to explcitly refresh it via dbms_mview, with:

alter materialized view view_name refresh on demand;

This seems fairly clear in the documentation.

If you really want to permanently disable refresh, even manually, so you're left with the current contents and they can not be updated from the view query, you can drop the materialized view but keep the backing table:

drop materialized view view_name preserve table;

This is obviously more radical. And view_name will now just be an ordinary table, essentially as if you'd done create table view_name as <view query>.

like image 114
Alex Poole Avatar answered Sep 20 '22 13:09

Alex Poole