You can control whether a materialized view is available for use by the database server by enabling or disabling it. A disabled materialized view is also not considered by the optimizer during optimization. If a query explicitly references a disabled materialized view, the query fails and an error is returned. When you disable a materialized view, the database server drops the data for the view, but keeps the definition in the database. When you re-enable a materialized view, it is in an uninitialized state and you must refresh it in order to populate it with data.
Non-materialized views that are dependent on a materialized view are automatically disabled by the database server if the materialized view is disabled. As a result, once you re-enable a materialized view, you must re-enable all dependent views. For this reason, you may want to determine the list of views dependent on the materialized view before disabling it. You can do this using the sa_dependent_views system procedure. This procedure examines the ISYSDEPENDENCY system table and returns the list of dependent views, if any.
When you disable a materialized view, all indexes for it are also dropped and must be recreated, if necessary, when the view is re-enabled.
Connect to the database as the DBA, or as owner of the materialized view.
Open the Views folder for that database.
Select the materialized view and then choose File > Recompile and Enable.
Connect to the database as the DBA, or as owner of the materialized view.
Open the Views folder for that database.
Select the materialized view and then choose File > Disable.
Connect to the database as the DBA, or as owner of the materialized view.
Execute an ALTER MATERIALIZED VIEW ... ENABLE statement.
Execute a REFRESH MATERIALIZED VIEW to initialize the view and populate it with data.
Connect to the database as the DBA, or as owner of the materialized view.
Execute an ALTER MATERIALIZED VIEW ... DISABLE statement.
The following example disables the EmployeeConfidential materialized view. The data for the materialized view is dropped, the definition for the materialized remains in the database, the materialized view is unavailable for use by the database server, and dependent views, if any, are disabled.
ALTER MATERIALIZED VIEW EmployeeConfidential DISABLE;
The following two statements, respectively, re-enable the EmployeeConfidential materialized view, and then populate it with data.
ALTER MATERIALIZED VIEW EmployeeConfidential ENABLE; REFRESH MATERIALIZED VIEW EmployeeConfidential;