Question
What is view and materialized view ? What is the difference?
A
Anonymous
January 6, 2026

Answer

View:

A view is a virtual table based on a SQL query.

  1. It does not store data physically.
  2. Every time you query a view, the database re-runs the underlying SELECT query to fetch the latest data.
  3. Think of it as a saved query that behaves like a table.

Example: Creating a View

CREATE VIEW employee_salaries AS
SELECT emp_id, first_name, last_name, salary
FROM employees
WHERE active = 1;


Materialized View

A materialized view is a physical copy of the result of a SQL query.

  1. It stores data on disk.
  2. It must be refreshed (manually or automatically) to update its data.
  3. It is used to speed up performance, especially for heavy queries.

Example : Create a Materialized View

CREATE MATERIALIZED VIEW sales_summary AS
SELECT product_id, SUM(amount) AS total_sales
FROM sales
GROUP BY product_id;


1767733987514-iduursgmhil.png


Quick Memory Trick

  1. View = Live data (always fresh, but slower).
  2. Materialized View = Stored snapshot (faster, but may be outdated).



SeniorJuniorDatabase
Loading comments...
What is view and materialized view ? What is the difference? — Database Appian Interview Question | Appian Interview Questions - AppianVerse