Tuesday, 13 August 2013

Materialized Views

What is a Materialized View?

    A materialized view is a replica of a target master from a single point in time. The master can be either a master table at a master site or a master materialized view at a materialized view site. Where as in multi master replication tables are continuously updated by other master sites, materialized views are updated from one or more masters through individual batch updates, known as a refreshes, from a single master site or master materialized view site, as illustrated in. The arrows in represent database links.

Materialized View Connected to a Single Master Site

Read-Only Materialized Views


You can make a materialized view read-only during creation by omitting the FOR UPDATE clause or disabling the equivalent option in the Replication Management tool.
SQL>CREATE MATERIALIZED VIEW hr.employees AS SELECT * FROM hr.employees@orc1.world;

Updatable Materialized Views


You can make a materialized view updatable during creation by including the FOR UPDATE clause or enabling the equivalent option in the Replication Management tool. For changes made to an updatable materialized view to be pushed back to the master during refresh, the updatable materialized view must belong to a materialized view group.

SQL>CREATE MATERIALIZED VIEW hr.departments FOR UPDATE AS SELECT * FROM hr.departments@orc1.world;

Writeable Materialized Views

A writeable materialized view is one that is created using the FOR UPDATE clause but is not part of a materialized view group. Users can perform DML operations on a writeable materialized view, but if you refresh the materialized view, then these changes are not pushed back to the master and the changes are lost in the materialized view itself. Writeable materialized views are typically allowed wherever fast-refreshable read-only materialized views are allowed.


Required Privileges for Materialized View Operations

Three distinct types of users perform operations on materialized views:
  • Creator: the user who creates the materialized view
  • Refresher: the user who refreshes the materialized view
  • Owner: the user who owns the materialized view. The materialized view resides in this user's schema.

No comments:

Post a Comment