| PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 td> |
|
|
View PDF |
DBMS_MVIEW enables you to understand capabilities for materialized views and potential materialized views, including their rewrite availabil
ity. It also enables you to refresh materialized views that are not part of the same refresh group and purge logs.
See Also:
|
This chapter contains the following topics:
If a query is less than 256 characters long, you can invoke EXPLAIN_REWRITE using the EXECUTE command
from SQL*PLUS. Otherwise, the recommended method is to use a PL/SQL BEGIN..END block, as shown in the examples in /rdbms/demo/smxrw.sql.
The EXPLAIN_REWRITE procedure c
annot accept queries longer than 32627 characters. These restrictions also apply when passing the defining query of a materialized vi
ew to the EXPLAIN_MVIEW procedure.
This procedure performs a process to preserve materialized view data nee ded for refresh. It must be called before a master table is reorganized.
DBMS_MVIEW.BEGIN_TABLE_REORGANIZATIO N ( tabowner IN VARCHAR2, tabname IN VARCHAR2);< /a>
| Parameter | Description |
|---|---|
|
|
Owner of the table being reorganized. |
|
|
Name of the table being reorganized. |
This procedure ensures that the materialized view data for the master table is vali d and that the master table is in the proper state. It must be called after a master table is reorganized.
DB MS_MVIEW.END_TABLE_REORGANIZATION ( tabowner IN VARCHAR2, tabname IN VARCH AR2);
| Parameter | Descript ion |
|---|---|
|
|
Owner of the table being reorga nized. |
|
|
Name of the table being reorganized. |
This procedure estimates the size of a materialized view that you might create, in bytes and number of rows.
DBMS_MVIEW.ESTIMATE_MVIEW_SIZE ( stmt_id IN VARCHAR2, select_clause IN VARCHAR2, num_rows OUT NUMBE R, num_bytes OUT NUMBER);
| Parameter | Datatype | Description |
|---|---|---|
|
|
|
Arbitrary string used to identify the statement in an |
|
|
|
The |
|
|
|
|
|
|
a>
|
Estimated number of bytes. |
This procedure enables you to learn what is po ssible with a materialized view or potential materialized view. For example, you can determine if a materialized view is fast refresh able and what types of query rewrite you can perform with a particular materialized view.
Us
ing this procedure is straightforward. You simply call DBMS_MVIEW.EXPLAIN_MVIEW, passing in as parameters t
he schema and materialized view name for an existing materialized view. Alternatively, you can specify the SELECT string
or CREATE MATERIALIZED VIEW statement for a potential materialized view. The materialized vie
w or potential materialized view is then analyzed and the results are written into either a table called MV_CAPABILITIES_TABLE<
/code>, which is the default, or to an array called MSG_ARRAY.
The procedure i s overloaded:
MV_CAPABILITIES_TABLE.VARRAY:DBMS_MVIEW.EXPLAIN_MVIEW ( mv IN VARCHAR2, statement_id IN VARCHAR2:= NULL); DBMS_MVIEW.EXPLAIN_MVIEW ( mv IN V ARCHAR2, msg_array OUT SYS.ExplainMVArrayType);
You must run the utlxmv
.sql script to create MV_CAPABILITIES_TABLE in the current schema prior to calling EXPLAIN_MVIEW exc
ept when you direct output to a VARRAY. The script is found in the admin directory.
This procedure enables you to learn why a query failed to rewrite, or, if it rewrites, whi
ch materialized views will be used. Using the results from the procedure, you can take the appropriate action needed to make a query
rewrite if at all possible. The query specified in the EXPLAIN_REWRITE statement is never actually executed.
EXPLAIN_REWRITE in two ways. The first is to use a table, while the second i
s to create a VARRAY. The following shows the basic syntax for using an output table:
DBMS_MVIEW.EXPLAIN_REWRITE ( query IN [VARCHAR2 | CLOB], mv IN VARCHAR2, statement_id IN VARCHAR2;
If you want to direct the output of EXPLAIN_REWRITE to a VARRAY, instead of a table, then the proc
edure should be called as follows:
DBMS_MVIEW.EXPLAIN_REWRITE ( q uery IN [VARCHAR2 | CLOB], mv IN VARCHAR2, msg_array IN OUT SYS.RewriteArrayType);
To obtain the output into a table, you must run the utlxrw.sql script before calling EXPLAIN_REWRITE. This script creates a table named REWRITE_TABLE in the current
schema.
This function returns the value of the I_AM_REFRESH package state.
DBMS_MVIEW.I_AM_A_REFRESH RETURN BOOLEAN;
A return value of true indicates that all local replication triggers for materialized views are effectively
disabled in this session because each replication trigger first checks this state. A return value of false indicates tha
t these triggers are enabled.
This function returns a partition marker from a rowid. It is used for Partition Change Tracking (PCT).
DBMS_MVIEW.PMARKER( rid IN R OWID) RETURN NUMBER;
| Parameter | Description |
|---|---|
| <
a name="997086">
|
The rowid of a row entry in a master table. |
This pr ocedure removes entries from the direct loader log after they are no longer needed for any known materialized view. This procedure us ually is used in environments using Oracle's data warehousing technology.
| See Also:
Oracle Data Warehousing Guide for more information |
DBMS_MVIEW.PURGE_DIRECT_LOAD_LOG();
This pro cedure purges rows from the materialized view log.
DBMS_MVIEW.PURGE_LOG ( master IN VARCHAR2, num IN BINARY_INTEGER := 1, flag IN VARCHAR2 := 'NOP');
| Parameter | Description |
|---|---|
|
|
Name of the master table or master m aterialized view. |
|
|
Number of least recently refreshed materialized vi ews whose rows you want to remove from materialized view log. For example, the following statement deletes rows needed to refresh the two least recently refreshed materialized views:
To delete all rows in the materialized view log, indicate a high number of materia lized views to disregard, as in this example:
This statement completely purges the materialized view log that corresponds to |
|
|
Specify
|
|
Note: This procedure is overloaded. The |
If there is an error while purging one of the materialized view logs, the successful purge operations of the previ ous materialized view logs are not rolled back. This is to minimize the size of the materialized view logs. In case of an error, this procedure can be invoked again until all the materialized view logs are purged.
This procedure refreshes a list of materialized views.
DBMS_MVIEW.REFRESH ( { li st IN VARCHAR2, | tab IN DBMS_UTILITY.UNCL_ARRAY,} method IN VARCHAR2 := NULL, rollback_seg IN VARCHAR2 := NULL, push_deferred_rpc IN BOOLEAN := true, refresh_after_errors IN BOOLEAN := false, purge_option IN BINARY_INTEGER := 1, para llelism IN BINARY_INTEGER := 0, heap_size IN BINARY_INTEGER := 0, atomic_refresh IN BOOLEAN := true, nested IN BOOLEAN := false);
This procedur e refreshes all materialized views that have the following properties:
DBA_MVIEWS.This procedure is intended for use with data warehouses .
DBMS_MVIEW.REFRESH_ALL_MVIEWS ( number_of_failures OUT BINARY_INTEGER, method IN VARCHAR2 := NULL, rollback_seg IN VARCHAR 2 := NULL, refresh_after_errors IN BOOLEAN := false, atomic_ref resh IN BOOLEAN := true);
| |
Description |
|---|---|
|
|
Returns the number of failures that occurred during processing. |
|
|
<
/a>
A single refresh method indicating the type of refresh to perform for each materialized view that is refreshed. |
|
|
Name of the materialized view site rollback segment to use while refreshing materialized views. |
|
|
If this parameter is |
|
|
If this parameter is set to If this parameter is set to |
This procedure refreshes al l materialized views that have the following properties:
DBA_MVIEWS.This procedure is intended for use wit h data warehouses.
DBMS_MVIEW.REFRESH_DEPENDENT ( number_of_failures OUT BINAR Y_INTEGER, { list IN VARCHAR2, | tab IN DBMS _UTILITY.UNCL_ARRAY,} method IN VARCHAR2 := NULL, rollback_seg IN VARCHAR2 := NULL, refresh_after_errors IN BOOLEAN := false, < /a> atomic_refresh IN BOOLEAN := true, nested IN BOOLEAN := false) ;
This procedure enables the administration of individual materialized views. It is invo ked at a master site or master materialized view site to register a materialized view.
Note that, typically, a materialized view is registered automatically during materialized view creation. You should only run this procedu re to manually register a materialized view if the automatic registration failed or if the registration information was deleted.
< a name="997413">DBMS_MVIEW.REGISTER_MVIEW ( mviewowner IN VARCHAR2, mviewname IN VARCHAR2, mviewsite IN VARCHAR2, mview_id IN DATE | BINARY_INTEGER, < a name="997418"> flag IN BINARY_INTEGER, qry_txt IN VARCHAR2, re p_type IN BINARY_INTEGER := DBMS_MVIEW.REG_UNKNOWN);
mviewowner
Owner of the materialized view.
mviewname
Name of the materialized view.
mviewsite
Name of the materialized view site for a materialized view registering at an Oracle database version 8.x and higher master site or master materialized view s ite. This name should not contain any double quotes.
mview_id
The identi
fication number of the materialized view. Specify an Oracle database version 8.x and higher materialized view as a BINARY_INTEG
ER. Specify an Oracle database version 7 materialized view registering at an Oracle database version 8.x and higher master sit
es or master materialized view sites as a DATE.
flag
A cons tant that describes the properties of the materialized view being registered. Valid constants that can be assigned include the follow ing:
DBMS_MVIEW.REG_ROWID_MVIEW for a rowid materialized view <
/a>
DBMS_MVIEW.REG_PRIMARY_KEY_MVIEW for a primary key materialized view
DBMS_MVIEW.REG_OBJECT_ID_MVIEW for an object id materialized view
DBMS_MVIEW.REG_UPDATABLE_MVIEW for a materialized view that is updatable
A materialized view can have more than one of these properties. In this case, use the plus sign (+) to specify more than one property . For example, if a primary key materialized view can be fast refreshed, you can enter the following for this parameter:
DBMS_MVIEW.REG_PRIMARY_KEY_MVIEW + DBMS_MVIEW.REG_FAST_REFRESHABLE_MVIEW
You can determine the properties of a materialized view by querying the ALL_MVIEWS data dictionary view.
qry_txt
The first 32,000 bytes of the materialized view definition query.
< /td>rep_type
Version of the materialized view. Valid constants that can be assig ned include the following:
DBMS_MVIEW.REG_V7_SNAPSHOT if the materialized view i
s at an Oracle database version 7 site
DBMS_MVIEW.REG_V8_SNAPSHOT if the materia
lized view is at an Oracle database version 8.x or higher site
DBMS_MVIEW.REG_UNKNOWN
code> (the default) if you do not know whether the materialized view is at an Oracle database version 7 site or an Oracle database ve
rsion 8.x (or higher) site
This procedure is invoked at the master site or mas
ter materialized view site by a remote materialized view site using a remote procedure call. If REGISTER_MVIEW is called
multiple times with the same mviewowner, mviewname, and mviewsite, then the most recent value
s for mview_id, flag, and qry_txt are stored. If a query exceeds the maximum VARCHAR2 size, then qry_txt contains the first 32000 characters of the query and the remainder is truncated. When invoked ma
nually, the value of mview_id must be looked up in the materialized view data dictionary views by the person who calls t
he procedure.
This procedure enables the administration of individu al materialized views. It is invoked at a master site or master materialized view site to unregister a materialized view.
DBMS_MVIEW.UNREGISTER_MVIEW ( mviewowner IN VARCHAR2, mviewname IN VARCHAR2, mviewsite IN VARCHAR2);
| Parameters | Description |
|---|---|
|
|
Owner of the materialized view. |
|
|
Name of the materialized view. |
| <
/a>
|
Name of the materialized v iew site. |