Re: table alias

From: Bob(dot)Henkel(at)hartfordlife(dot)com
To: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: table alias
Date: 2004-05-25 14:43:47
Message-ID: OFAE494B3D.EC496A49-ON86256E9F.00503469-86256E9F.0050E6D3@hartfordlife.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)moncure(at)rcs|
| | online.com> |
| | |
| | 05/25/2004 09:20 AM|
| | |
|---------+------------------------------>
>------------------------------------------------------------------------------------------------------------------------------|
| |
| To: <Bob(dot)Henkel(at)hartfordlife(dot)com> |
| cc: <pgsql-hackers-win32(at)postgresql(dot)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 contain proprietary, 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, please notify the sender immediately by return e-mail, delete this communication and destroy all copies.
*************************************************************************

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Tom Lane 2004-05-25 14:52:50 Re: table alias
Previous Message Merlin Moncure 2004-05-25 14:20:54 Re: table alias