PostgreSQL 11 Administration Cookbook
by Simon Riggs, Gianni Ciolli, Sudheer Kumar Meesala, Sheldon Strauch
How to do it…
There is nothing to do for simple views—PostgreSQL will propagate modifications to the underlying table automatically.
Conversely, if the view is not simple enough, but you still have a clear idea of how you would like to propagate changes to the underlying table(s), then you can allow updatable views by telling PostgreSQL how to actually perform Data Manipulation Language (DML) statements, which in PostgreSQL means INSERT, UPDATE, DELETE, or TRUNCATE.
PostgreSQL supports two mechanisms to achieve updatable views, namely rewrite rules and INSTEAD OF triggers. The latter provide a mechanism to implement updatable views by creating trigger functions that execute arbitrary code every time a data-modification command is executed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access