What is a VIEW in PostgreSQL?

Answer

A view is a named query stored in the database that can be referenced like a table. It does not store data itself (unless it's a materialized view). Views simplify complex queries, encapsulate business logic, and control data access (show only certain columns to certain users). Create: CREATE VIEW active_users AS SELECT id, name, email FROM users WHERE is_active = true;. Query: SELECT * FROM active_users;. Update a view: CREATE OR REPLACE VIEW active_users AS .... Simple views (single-table, no aggregation, no DISTINCT) are updatable — you can INSERT/UPDATE/DELETE through them. Complex views require a RULE or INSTEAD OF trigger for updates.