Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh materialized view in oracle

Iam trying to refresh the materialized view by using:

DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')

But it's throwing invalid sql statement.

Then I have created a stored procedure like this:

CREATE OR REPLACE 
PROCEDURE MAT_VIEW_FOO_TBL 
IS
BEGIN
   DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')
END MAT_VIEW_FOO_TBL IS;

This procedure has been created successfully but when i am calling this procedure with

MAT_VIEW_FOO_TBL;

it's throwing an error again.

Kindly suggest a solution for this issue.

Thanks, Srinivas

like image 363
Srinivas Avatar asked Jul 19 '12 06:07

Srinivas


People also ask

How do you refresh materialized view?

To update the data in a materialized view, you can use the REFRESH MATERIALIZED VIEW statement at any time. When you use this statement, Amazon Redshift identifies changes that have taken place in the base table or tables, and then applies those changes to the materialized view.

How do you refresh a materialized view daily?

So if you want to refresh mview daily, you need to keep it refresh on demand and set the next refresh time as sysdate + 1 . You can set any interval although. Once you do this the materialized view is created and a job is set in Oracle that will refresh mview every 24 hrs (sysdate + 1) .

What are the types of refresh in materialized view Oracle?

Materialized views can be refreshed in two ways: fast or complete.

What is force refresh in materialized view?

How do I force a refresh of a materialized view? Answer: Oracle provides the dbms_mview package to manually invoke either a fast refresh or a complete refresh, where F equals Fast Refresh and C equals Complete Refresh: execute dbms_mview.refresh('emp_dept_sum','f'); Get the Complete. Oracle SQL Tuning Information.


2 Answers

Run this script to refresh data in materialized view:

BEGIN DBMS_SNAPSHOT.REFRESH('Name here'); END; 
like image 113
Waqas Ali Avatar answered Oct 06 '22 10:10

Waqas Ali


try this:

DBMS_SNAPSHOT.REFRESH( 'v_materialized_foo_tbl','f'); 

first parameter is name of mat_view and second defines type of refresh. f denotes fast refresh. but keep this thing in mind it will override any any other refresh timing options.

like image 20
fahim ashraf Avatar answered Oct 06 '22 09:10

fahim ashraf