6.2. Updatable and Read-Only VIEWs

Unlike base tables, VIEWs are either updatable or read-only, but not both, INSERT, UPDATE, and DELETE operations are allowed on updatable VIEWs and base tables, subject to any other constraints, INSERT, UPDATE, and DELETE are not allowed on read-only VIEWs, but you can change their base tables, as you would expect.

An updatable VIEW is one that can have each of its rows associated with exactly one row in an underlying base table. When the VIEW is changed, the changes pass through the VIEW to that underlying base table unambiguously. Updatable VIEWs in Standard SQL are defined only for queries that meet these criteria:

  1. Built on only one table

  2. No GROUP BY clause

  3. No HAVING clause

  4. No aggregate functions

  5. No calculated ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.