Examples Of Create Materialized View - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

You can create additional secondary indexes, which cannot be unique.
Joins
An inner equi-join query is a query where rows from each table are matched to specific rows
in other tables using equal predicates.
Outer joins include LEFT OUTER JOIN or FULL OUTER JOIN.
In a cross join, not all predicates are given so each row of a table is matched with all the rows
of the other table.
Restrictions for CREATE MATERIALIZED VIEW
The following restrictions specify what materialized view types can be defined as incremental.
MJV (Materialized Join View)
Only inner equi-joins are supported; outer joins and cross joins are not supported.
Must be a single block SELECT-FROM-WHERE query (for example, UNION, ORDER BY,
subqueries, TRANSPOSE, and SAMPLE are not allowed).
SELECT DISTINCT is not supported.
Aggregates are not allowed in the select list.
MAV (Materialized Aggregate View)
The MAV can also be defined on a previously defined materialized view.
The HAVING clause is not allowed.
The DISTINCT function is not supported.
Aggregates must be top-most functions and they cannot contain nested aggregates (for
example, no AVG(X)+1).
Under certain conditions when the MAX or MIN function is used in a MAV, the incremental
refresh of the materialized view returns an error and the materialized view needs to be
recomputed. This is because if a row that contains the MAX or MIN value of its group is
deleted from the base table, a new value cannot be incrementally computed. The failure of
an incremental refresh operation of a MAV, because of the deletion of the MIN or MAX
value, can be avoided:
— if an even greater (or smaller) value was inserted, it is the new MAX (or MIN) value
— if the base table is in insert-only table, mark it as INSERTLOG
— add an index on the base table on the columns that are used as the materialized views
group by columns. When such a supporting index exists, the new MAX or MIN value
can be computed without a full scan on the base table, keeping the REFRESH
incremental.
If none of these options is used, the materialized view has to be recomputed.
The columns in the GROUP BY clause cannot exceed the maximum key length limit.
Must be a single block SELECT-FROM-WHERE-GROUPBY query (for example, ORDER
BY is not allowed). There is one exception to this rule; nested blocks are allowed when the
inner block's purpose is to extract a group by column (using a built-in function like substring
or extract).
Non-repeatable expressions (for example, current_time) are not supported for all types
of aggregate materialized views.

Examples of CREATE MATERIALIZED VIEW

This is an example of an aggregate MAV:
CREATE MATERIALIZED VIEW PUBSCH.DETAIL_MV
REFRESH ON REQUEST
INITIALIZE ON REFRESH
CREATE MATERIALIZED VIEW Statement
67

Advertisement

Table of Contents
loading

Table of Contents