Re: Why the "UPDATE tab SET tab.col" is invalid?

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why the "UPDATE tab SET tab.col" is invalid?
Date: 2016-04-07 14:51:56
Message-ID: CAEzk6ffXhvYhJ-51vNuLUZ5Dv57igqwz6GCxFNXj6wFfvZFmPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7 April 2016 at 14:48, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>
> On Thu, Apr 7, 2016 at 4:39 AM, postgres_sure <postgres_sure(at)163(dot)com> wrote:
> > Hi,
> >
> > I found "Do not include the table's name in the specification of a target
> > column
> > — for example, UPDATE tab SET tab.col = 1 is invalid." in
> > the documentation.
> >
> > Some people usually like to update table by alias. They want to add this
> > feature.
>
> Is this syntax described in the SQL standard?

Given that the SQL standard has no concept of UPDATEs against a query
with multiple tables, and that's where this could bring the most
clarity, I'm not sure that it's reasonable to object on that basis.

As far as I can see the SQL standard doesn't let you alias tables in
an UPDATE (for the same reason, I imagine) but we allow _that_ even in
a single-table UPDATE.

<update statement: positioned> ::=
UPDATE <table name>
SET <set clause list>
WHERE CURRENT OF <cursor name>

Geoff

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Geoff Winkless 2016-04-07 14:55:00 Re: Why the "UPDATE tab SET tab.col" is invalid?
Previous Message Tom Lane 2016-04-07 14:46:26 Re: Performance improvement for joins where outer side is unique