Re: table alias - Mailing list pgsql-hackers-win32

From Bob.Henkel@hartfordlife.com
Subject Re: table alias
Date
Msg-id OFAE494B3D.EC496A49-ON86256E9F.00503469-86256E9F.0050E6D3@hartfordlife.com
Whole thread Raw
In response to table alias  (Bob.Henkel@hartfordlife.com)
List pgsql-hackers-win32




The reason I brought this up is I come from an Oracle background and had
used aliases in all kinds of statements.  For Oracle Development I also use
a SQL editor  that has auto complete so when I alias a table and than put a
period after the alias it lists all the columns for that table.  So out of
habit I alias everything.

This makes me type much less when writing SQL scripts all day.  It comes in
handy even when you are doing an update which is only one table but have to
update 20+ columns.  Mainly me being lazy, but hey what good are computers
for if a guy can't be a little lazy and still accomplish his goals.
Definitely not a feature I need to be happy.

Thanks for the info



|---------+------------------------------>
|         |           "Merlin Moncure"   |
|         |           <merlin.moncure@rcs|
|         |           online.com>        |
|         |                              |
|         |           05/25/2004 09:20 AM|
|         |                              |
|---------+------------------------------>

>------------------------------------------------------------------------------------------------------------------------------|
  |
        | 
  |       To:       <Bob.Henkel@hartfordlife.com>
        | 
  |       cc:       <pgsql-hackers-win32@postgresql.org>
        | 
  |       Subject:  RE: [pgsql-hackers-win32] table alias
        | 

>------------------------------------------------------------------------------------------------------------------------------|




> I'm running a binary snapshot from two days ago.  When I run a update
with
> aliases the SQL doesn't work.  The alias does work if I run just a
select
> statement however.  Is this suppose to be like this.  If not is it
only
> broken in the 7.5 WIN32 build?

Look at the grammar for select and update (\h update, \h select) in
psql.  You will notice that select has grammar for alias, update does
not

where from_item can be one of:

    [ ONLY ] table_name [ * ] [ [ AS ] alias [ ( column_alias [, ...] )
] ]
    ( select ) [ AS ] alias [ ( column_alias [, ...] ) ]
    function_name ( [ argument [, ...] ] ) [ AS ] alias [ ( column_alias
[, ...] | column_definition

there is no reason to alias the update statement because you can only
specify one table, so it is not really necessary to prefix each column
with the table name (and thus no reason for an alias).  I didn't check,
but the unix version almost certainly works the same

Merlin







*************************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is for the exclusive use of addressee and may
containproprietary, confidential and/or privileged information.  If you are not the intended recipient, any use,
copying,disclosure, dissemination or distribution is strictly prohibited.  If you are not the intended recipient,
pleasenotify the sender immediately by return e-mail, delete this communication and destroy all copies. 
*************************************************************************


pgsql-hackers-win32 by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: table alias
Next
From: Tom Lane
Date:
Subject: Re: table alias