From: Paul Förster <paul.foerster@gmail.com>
To: Wells Oliver <wells.oliver@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: UPDATE works on a view?
Date: Thu, 6 Aug 2020 07:56:27 +0200
Message-ID: <ACCB0592-8786-4E68-8250-39ADF143BF37@gmail.com> (raw)
In-Reply-To: <CAOC+FBUYTaQ+Sk2tA24NdExek4_-S5q4Oe86Bx4K_6Th5F-aWQ@mail.gmail.com>
References: <CAOC+FBUYTaQ+Sk2tA24NdExek4_-S5q4Oe86Bx4K_6Th5F-aWQ@mail.gmail.com>
Hi Oliver,
> On 05. Aug, 2020, at 20:30, Wells Oliver <wells.oliver@gmail.com> wrote:
>
> Err, sorry if this is back to basics, but I was very confused by someone being able to UPDATE myview SET col = 1 and the underlying table actually being updated properly.
>
> Is this recent? When did we become able to UPDATE on views?
yes, this is possible:
postgres=# create table t(i int);
CREATE TABLE
postgres=# create view v(i) as select i from t;
CREATE VIEW
postgres=# insert into v(i) values (0);
INSERT 0 1
postgres=# select * from v;
i
---
0
(1 row)
postgres=# update v set i=3;
UPDATE 1
postgres=# select * from v;
i
---
3
(1 row)
But I don't know since which PostgreSQL version views can up updated.
Cheers,
Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: paul.foerster@gmail.com, wells.oliver@gmail.com
Subject: Re: UPDATE works on a view?
In-Reply-To: <ACCB0592-8786-4E68-8250-39ADF143BF37@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox