A materialized view log is a table associated with the master table of a materialized view. Use the
LOG statement to alter the storage characteristics or type of an existing materialized view log.
SNAPSHOTis supported in place of
VIEWfor backward compatibility.
You must be the owner of the master table or you must have the
SELECT privilege on the master table and the
ALTER privilege on the materialized view log.
See Also:Oracle Database Advanced Replication for detailed information about the prerequisites for
(physical_attributes_clause::=, add_mv_log_column_clause::=, alter_table_partitioning ::= (in
TABLE), parallel_clause::=, logging_clause::=, allocate_extent_clause::=, shrink_clause::=, move_mv_log_clause::=, mv_log_augmentation::=,mv_log_purge_clause::=.)
If you specify
FORCE and any items specified with the
ADD clause have already been specified for the materialized view log, then Oracle Database does not return an error, but silently ignores the existing elements and adds to the materialized view log any items that do not already exist in the log. Likewise, if you specify
VALUES and that attribute has already been specified for the materialized view log, Oracle Database ignores the redundancy and does not return an error.
Specify the schema containing the master table. If you omit
schema, then Oracle Database assumes the materialized view log is in your own schema.
Specify the name of the master table associated with the materialized view log to be altered.
physical_attributes_clause lets you change the value of the
INITRANS parameters and the storage characteristics for the materialized view log, the partition, the overflow data segment, or the default characteristics of a partitioned materialized view log.
Restriction on Materialized View Log Physical Attributes You cannot use the
storage_clause to modify extent parameters if the materialized view log resides in a locally managed tablespace. Refer to CREATE TABLE for a description of these parameters.
When you add a column to the master table of the materialized view log, the database does not automatically add a column to the materialized view log. Therefore, use this clause to add a column to the materialized view log. Oracle Database will encrypt the newly added column if the corresponding column of the master table is encrypted.
The syntax and general functioning of the partitioning clauses is the same as described for the
TABLE statement. Refer to alter_table_partitioning in the documentation for
You cannot use the
modify_LOB_storage_clause when modifying partitions of a materialized view log.
If you attempt to drop, truncate, or exchange a materialized view log partition, then Oracle Database raises an error.
parallel_clause lets you specify whether parallel operations will be supported for the materialized view log.
For complete information on this clause, refer to parallel_clause in the documentation on
Specify the logging attribute of the materialized view log. Refer to the logging_clause for a full description of this clause.
allocate_extent_clause to explicitly allocate a new extent for the materialized view log. Refer to allocate_extent_clause for a full description of this clause.
Use this clause to compact the materialized view log segments. For complete information on this clause, refer to shrink_clause in the documentation on
MOVE clause to move the materialized view log table to a different tablespace, to change other segment or storage attributes of the materialized view log, or to change the parallelism of the materialized view log.
For data that will be accessed frequently,
CACHE specifies that the blocks retrieved for this log are placed at the most recently used end of the LRU list in the buffer cache when a full table scan is performed. This attribute is useful for small lookup tables.
NOCACHE specifies that the blocks are placed at the least recently used end of the LRU list. Refer to "CACHE | NOCACHE | CACHE READS" in the documentation on
TABLE for more information about this clause.
ADD clause to augment the materialized view log so that it records the primary key values, rowid values, object ID values, or a sequence when rows in the materialized view master table are changed. This clause can also be used to record additional columns.
To stop recording any of this information, you must first drop the materialized view log and then re-create it. Dropping the materialized view log and then re-creating it forces a complete refresh for each of the existing materialized views that depend on the master table on its next refresh.
Restriction on Augmenting Materialized View Logs You can specify only one
SEQUENCE, and each column in the column list once for each materialized view log. You can specify only a single occurrence of
SEQUENCE, and column list within this
ALTER statement. Also, if any of these values was specified at create time (either implicitly or explicitly), you cannot specify that value in this
ALTER statement unless you use the
column Specify the additional columns whose values you want to be recorded in the materialized view log for all rows that are changed. Typically these columns are filter columns (non-primary-key columns referenced by subquery materialized views) and join columns (non-primary-key columns that define a join in the
WHERE clause of the subquery).
VALUES clause lets you specify whether Oracle Database saves both old and new values for update DML operations in the materialized view log. The value you set in this clause applies to all columns in the log, not only to columns you may have added in this
INCLUDING to save both new and old values in the log. If this log is for a table on which you have a single-table materialized aggregate view, and if you want the materialized view to be eligible for fast refresh, then you must specify
If you have a fast-refreshable single-table materialized aggregate view defined on this table, then do not specify
VALUES unless you first change the refresh mode of the materialized view to something other than
Use this clause alter the purge attributes of the materialized view log in the following ways:
Change the purge from
ASYNCHRONOUS or from
Change the purge from
IMMEDIATE to scheduled or from scheduled to
Specify a new start time and a new
next time and
If you are altering purge from scheduled to
IMMEDIATE, then the scheduled purged job associated with that materialized view log is dropped. If you are altering purge from
IMMEDIATE to scheduled, then a purge job is created with the attributes provided. If you are altering scheduled purge attributes, then only those attributes specified will be changed in the scheduler purge job.
You must specify
FORCE if you are altering log purge to its current state (that is, you are not making any change), unless you are changing scheduled purge attributes.
To learn whether the purge time or interval has already been set for this materialized view log, query the
*_MVIEW_LOGS data dictionary views. See the
LOG clause mv_log_purge_clause for the full semantics of this clause.
ALTER MATERIALIZED VIEW LOG ON order_items ADD ROWID;
Materialized View Log EXCLUDING NEW VALUES: Example The following statement alters the materialized view log on
hr.employees by adding a filter column and excluding new values. Any materialized aggregate views that use this log will no longer be fast refreshable. However, if fast refresh is no longer needed, this action avoids the overhead of recording new values:
ALTER MATERIALIZED VIEW LOG ON employees ADD (commission_pct) EXCLUDING NEW VALUES;