ALTER MATERIALIZED VIEW REBUILD
You must rebuild the materialized view to keep it up-to-date when changes to the data occur.
Syntax
ALTER MATERIALIZED VIEW [db_name.]materialized_view_name REBUILD;
- db_name.materialized_view_name
- The database name followed by the name of the materialized view in dot notation.
Description
A rewrite of a query based on a stale materialized view does not occur automatically. If
you want a rewrite of a stale or possibly stale materialized view, you can force a rewrite.
For example, you might want to use the contents of a materialized view of a
non-transactional table because the freshness of such a table is unknown. To enable
rewriting of a query based on a stale materialized view, you can run the rebuild operation
periodically and set the following property:
hive.materializedview.rewriting.time.window
. For example, SET
hive.materializedview.rewriting.time.window=10min;
Example
ALTER MATERIALIZED VIEW mydb.mv1 REBUILD;