REFRESH

Bring a materialised view up to date with its source.

Syntax

Write REFRESH and the view's name. Several names can be separated by commas, and a name may be quoted.

REFRESH mv_name
REFRESH mv_first, mv_second
REFRESH "mv_name"

Parameters and arguments

  • view

    The name of a materialised view, plain or quoted. The name is read as lower case and must be lower case letters, digits and underscores beginning with mv_. A name with a dot, such as one qualified by a schema, is refused

    Required: At least one

The list has no fixed length. Each name is refreshed in the order written.

Examples

Recompute one materialised view.

Return type and behaviour

REFRESH answers that it succeeded and returns no rows. Each view is refreshed in turn with the concurrent form, so reads of the view are not blocked. The first view that fails stops the statement, and the views after it are not refreshed.

Errors and exceptions
ErrorWhat happenedHow to recover
HTQL-6001 REFRESH failed on the viewThe view does not exist, its name is not a permitted view name, or the database refused a concurrent refreshCheck the view's name: it begins with mv_. The message names the view and the reason
Placement and context

REFRESH is a statement of its own. It is not a step of a FOR loop.

Limitations
  • Only views whose names begin with mv_ can be refreshed.
  • A concurrent refresh needs the view to have a unique index and to have been populated once. A view without one is refused by the database.
Permissions and security

REFRESH runs through a protected routine that accepts only a name of the form mv_ followed by lower case letters, digits and underscores, and looks the view up in the platform's own schemas. A name of another form is refused. The engine checks no table permission for REFRESH beyond that name rule.

Best practices
  • Refresh a view after the data it summarises has changed.
  • Refresh several views in one statement when they belong together.
  • Put the view a report depends on first in the list, so a later failure does not leave it stale.