Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between compiling and refreshing a materialized view?

We just ran into a problem where materialized views weren't refreshing, and giving a compile error. One of the senior developers says he just figured out how to fix it -- by telling toad to compile the materialized view.

So my question is pretty simple: what's the difference between a refresh and a "compile"?

like image 947
jldugger Avatar asked Sep 26 '11 22:09

jldugger


Video Answer


2 Answers

A Refresh of a materialized view is a data operation. The data in the MV is brought up to date as specified when the view was created, e.g., fast refresh, complete refresh, etc.

When you compile the MV, Oracle revalidates the query upon which the view is based. Your MV may be invalid due to changes in one or more of the underlying objects upon which the MV is based.

like image 60
DCookie Avatar answered Oct 21 '22 05:10

DCookie


A refresh updates the data that the materialized view holds. This cannot be done if the materialized view's definition is invalid.

A compile validates the definition of the materialized view, i.e. that the SQL is valid and that the objects it relies on exist.

like image 44
Tony Andrews Avatar answered Oct 21 '22 05:10

Tony Andrews