Skip to main content
Stored query results in materialized view are not automatically updated to reflect the latest state of the table(s) they query. The REFRESH statement updates the stored query results of a materialized view.
CockroachDB does not support materialized views that are refreshed on transaction commit.

Required privileges

The user must be the owner of the materialized view or have admin privileges.

Synopsis

refresh_materialized_views syntax diagram

Parameters

Example

The following example uses the sample bank database, populated with some workload values. Suppose that you create a materialized view on the bank table:
Now suppose that you update the balance values of the bank table:
The changes can be seen in the table with a simple SELECT statement against the table:
Recall that materialized views do not automatically update their stored results. Selecting from overdrawn_accounts returns stored results, which are outdated:
To update the materialized view’s results, use a REFRESH statement:

See also