MATERIALIZED VIEW
MATERIALIZED VIEW is a SQL statement in the Views category. A view that physically stores the result. Unlike regular views, querying it does NOT re-execute the query. The syntax is CREATE MATERIALIZED VIEW view_name AS select_statement [WITH DATA];. It returns materialized view. A typical example: CREATE MATERIALIZED VIEW daily_sales_summary AS SELECT date, SUM(amount) AS total_sales, COUNT(*) AS order_count FROM orders GROUP BY date; -- Refresh periodically: REFRESH MATERIALIZED VIEW daily_sales_summary; -- Much faster than regular VIEW for large aggregations A close relative is CREATE VIEW, which creates a virtual table based on a SELECT query. Think of it as a saved query that acts like a table. A close relative is DROP VIEW, which removes a view from the database. Does not affect the underlying tables. A close relative is ALTER VIEW, which modifies an existing view definition. More about this category: Database views — CREATE VIEW, DROP VIEW, ALTER VIEW, materialized views.