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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.