Wednesday, October 31, 2012

How to fix materialized view corruption in Oracle database


A materialized view (mview) is an object or we can say it is a snapshot that used to store the query results. There are many advantages of materialized view like If you want to create mass deployment environment or you want to enable disconnecting computing & data subsetting then you should use materialized view to perform these task easily. On the other hand, the disadvantage of materialized view is that materialized view is also get corrupted just like databases.

You can repair materialized view but you have to take care some points:

1. To repair corrupt materialized view, you should refresh materialized view and ensure that the problem get resolved. You can manual refresh materialized view with the help of DBMS_SNAPSHOT and DBMS_MVIEW packages. 

DBMS_SNAPSHOT:

SQL> execute DBMS_SNAPSHOT.REFRESH( 'MV_EMP','f');

In the command the first parameter used for materialized view name & the second parameter is refresh types. There are two types of refresh options available in materialized view : Fast & Complete. 

You can also refresh all materialized view with the help of this command:

SQL> execute DBMS_SNAPSHOT.REFRESH_ALL;

DBMS_MVIEW is the synonym of DBMS_SNAPSHOT option to refresh materialized view. You can also use this option to refresh materialized view.

2. In case, the above procedure get failed then you should drop and re-create the materialized view: 

Command to drop materialized view:

DROP MATERIALIZED VIEW  EMP_mv;

Command to recreate materialized view:

CREATE MATERIALIZED VIEW EMP_mv;


In case the all steps get failed then you should use third party Oracle Database Recovery to repair corrupt materialized view. The software also repair Oracle database files. 

Hope the article will help you to fix Oracle database materialized view corruption!!

No comments:

Post a Comment