What is a View?

A view is a virtual table based on the result of a SELECT query. It does not store data itself.

Use Cases:

  • Hide sensitive columns
  • Pre-define complex joins or aggregations
  • Simplify access for end users

Example:

CREATE VIEW emp_summary AS
SELECT department_id, AVG(salary) AS avg_sal
FROM employees GROUP BY department_id;