CodeBlanks Logo Icon CodeBlanks

REFRESH

Refresh a materialized view.

REFRESH

REFRESH MATERIALIZED VIEW updates the stored result. Needed when the underlying table changes.

REFRESH MATERIALIZED VIEW daily_revenue;

This query recomputes the summary.

REFRESH — details

A materialized view does not auto-update. You refresh it manually with REFRESH.

In PostgreSQL, REFRESH MATERIALIZED VIEW CONCURRENTLY doesn't block reads during the refresh, but it requires a unique index on the view.

Practice REFRESH

Update the daily_revenue materialized view with REFRESH.

Starter code

query.sql
-- refresh mat view
REFRESH

Sample solution

query.sql
REFRESH MATERIALIZED VIEW daily_revenue;

Expected output

Materialized view güncellendi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 REFRESH: match the terms

Term Meaning
REFRESH update
MATERIALIZED VIEW physical view
manual manual
stale old

2 Add REFRESH

Question
____ MATERIALIZED VIEW daily_revenue;
Answer
REFRESH MATERIALIZED VIEW daily_revenue;

Explanation: REFRESH is the right answer.

3 When is a materialized view updated?

  • Automatically
  • Never
  • COMMIT ile
  • REFRESH ile Correct answer

Explanation: A materialized view is updated with REFRESH.

All lessons in Advanced