Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Overview of this book

Table of Contents (19 chapters)
PostgreSQL 9 Administration Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Updatable views


PostgreSQL supports the SQL standard CREATE VIEW command, which, starting from version 9.3, supports automatic UPDATE, INSERT, and DELETE commands, provided they are simple enough.

With older PostgreSQL versions or with more complex views, these operations can be simulated with suitable query rewrite rules, or more recently by INSTEAD OF triggers. Note that according to community support policies, at least until September 2017, there will be PostgreSQL versions prior to 9.3 that are still supported and do not support automatic updatable views. Therefore, if you are using version 9.3 or later, only the discussion in the Getting ready section of this recipe will be of interest; the rest is implemented automatically.

Note also that certain types of updates are forbidden just because it is either impossible or impractical to derive a corresponding list of modifications on the constituent tables. We'll discuss those issues here.

Getting ready

First, you need to consider that only...