Getting ready

First, you need to consider that only simple views can be made to receive insertions, updates, and deletions easily. The SQL standard differentiates between views that are simple updatable and more complex views that cannot be expected to be updatable.

So, before we proceed, we need to understand what a simple updatable view is and what it is not. Let's start from the cust table:

postgres=# SELECT * FROM cust; customerid | firstname | lastname | age ------------+-----------+----------+-----          1 | Philip    | Marlowe  |  38          2 | Richard   | Hannay   |  42          3 | Holly     | Martins  |  25          4 | Harry     | Palmer   |  36          4 | Mark      | Hall     |  47(5 rows)

We create a very simple view on top of it, like the following:

CREATE VIEW cust_view ASSELECT customerid ,firstname ...

Get PostgreSQL 10 Administration Cookbook 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.