What is a view in a database?

Answer

A view is a virtual table created by a stored SELECT query. It does not store data itself — it dynamically retrieves data from underlying tables each time it is queried. Benefits: simplify complex queries (encapsulate joins/aggregations), security (expose only certain columns to users), and data abstraction (hide table restructuring from application queries). Create: CREATE VIEW active_users AS SELECT * FROM users WHERE active = true. Materialized views (PostgreSQL, Oracle) store the query result physically and refresh on demand — faster reads at the cost of stale data.