Re: Saving view turns SELECT * into field list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ben Uphoff <buphoff(at)villagemd(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Saving view turns SELECT * into field list
Date: 2018-10-15 19:55:11
Message-ID: 17168.1539633311@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben Uphoff <buphoff(at)villagemd(dot)com> writes:
> Why, when I save a simple view like:
> SELECT * FROM a_table
> …does PostgreSQL turn the * into a field list like:
> SELECT field1, field2, field3, field4 FROM a_table
> ?

Because the SQL standard says we should. There's explicit text in there
to the effect that adding columns to the underlying table does not add
columns to the view. Which, I'm sure, is exactly what you wished would
happen ... but they say not to.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-10-15 19:55:21 Re: Saving view turns SELECT * into field list
Previous Message Ben Uphoff 2018-10-15 19:50:05 Saving view turns SELECT * into field list