Q46: When is a SQL View updatable directly via DML statements?

Difficulty:MediumTopic:Database Objects

A view can accept direct INSERT, UPDATE, or DELETE statements only if the underlying query meets strict criteria:

  1. The view references exactly one base table in its FROM clause.
  2. The query contains no aggregation clauses (GROUP BY, HAVING, SUM, AVG, COUNT).
  3. The query contains no set operations (UNION, INTERSECT, EXCEPT) or DISTINCT clauses.
  4. All target non-null columns missing from the view definition must have default values.
Key Takeaways
  • Views are updatable only when mapped cleanly to a single underlying base table.
  • Aggregations, set operations, and DISTINCT clauses prevent direct DML modifications on views.