From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Paul Förster <paul(dot)foerster(at)gmail(dot)com> |
Cc: | Wells Oliver <wells(dot)oliver(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: UPDATE works on a view? |
Date: | 2020-08-06 10:20:13 |
Message-ID: | CABUevEx-ymj4O780QS48qewJ1HygM3AXJ4UrtL7GRw8aPaijew@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Thu, Aug 6, 2020 at 7:56 AM Paul Förster <paul(dot)foerster(at)gmail(dot)com> wrote:
> Hi Oliver,
>
> > On 05. Aug, 2020, at 20:30, Wells Oliver <wells(dot)oliver(at)gmail(dot)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.
>
>
For this type of high level features, the Feature Matrix is a pretty good
way to find out these things (
https://www.postgresql.org/about/featurematrix/#views-materialized-views)
Updatetable views was 9.3, WITH CHECK was 9.4.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Förster | 2020-08-06 10:30:34 | Re: UPDATE works on a view? |
Previous Message | Paul Förster | 2020-08-06 05:56:27 | Re: UPDATE works on a view? |