Updatable views
By default, simple PostgreSQL views are auto-updatable. Auto-updatable means that one could use the view with the DELETE
, INSERT
and UPDATE
statements to manipulate the data of the underlying table. If the view is not updatable (which is not simple) due to the violation of one of the following constraints, the trigger and rule systems can be used to make it updatable. The view is automatically updatable if the following conditions are met:
- The view must be built on top of one table or an updatable view.
- The view definition must not contain the following clauses and set operators at the top level:
DISTINCT
,WITH
,GROUP BY
,OFFSET
,HAVING
,LIMIT
,UNION
,EXCEPT
, andINTERSECT
. - The view's select list must be mapped to the underlying table directly without using functions and expressions. Moreover, the columns in the select list should not be repeated.
- The
security_barrier
property must not be set. The preceding conditions promise that the view attributes can be mapped directly to...