Skip site navigation (1) Skip section navigation (2)

Re: Table Alias posing problem in Update statements

From: Ingmar Lötzsch <iloetzsch(at)asci-systemhaus(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Table Alias posing problem in Update statements
Date: 2008-09-02 15:26:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Read the SQL-Reference for your version. For PostgreSQL 8.1.3 this is

UPDATE [ ONLY ] table SET column = { expression | DEFAULT } [, ...]
     [ FROM fromlist ]
     [ WHERE condition ]

UPDATE changes the values of the specified columns in all rows that 
satisfy the condition. Only the columns to be modified need be mentioned 
in the SET clause; columns not explicitly modified retain their previous 

By default, UPDATE will update rows in the specified table and all its 
subtables. If you wish to only update the specific table mentioned, you 
must use the ONLY clause.

There are two ways to modify a table using information contained in 
other tables in the database: using sub-selects, or specifying 
additional tables in the FROM clause. Which technique is more 
appropriate depends on the specific circumstances.

You must have the UPDATE privilege on the table to update it, as well as 
the SELECT privilege to any table whose values are read in the 
expressions or condition.

The name (optionally schema-qualified) of the table to update.

That means there is no alias allowed in UPDATE.


Pushker Chaubey schrieb:
> Hi experts,
> I am facing a problem using a Alias on a table while updating that table.
> I am trying something like
> T2.col3 = T1.col1)
> T1 and T2 are table aliases.
> Here I am trying to update a column in all the rows in table "Table1" 
> depending on value of another column for the same row.
> But the query is not working. It is not allowing alias in the update 
> query (i.e. alias T1 on table "Table1").
> Am I making a mistake somewhere in the syntax? Or, is it just not 
> supported in postgresql?
> I am using postgreSQL version 8.2.
> I have observed similar problems with delete statements also.
> But these types of queries run successfully on Oracle.
> Thanks in advance.
> Pushker Chaubey

In response to

pgsql-jdbc by date

Next:From: Richard BroersmaDate: 2008-09-02 22:01:54
Subject: JDBC driver feature implementation lists
Previous:From: Oliver JowettDate: 2008-09-01 22:36:38
Subject: Re: UPDATE ... CURRENT OF cursorname

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group