Re: AS operator and subselect result names: PostgreSQL

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Neil Zanella <nzanella(at)cs(dot)mun(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: AS operator and subselect result names: PostgreSQL
Date: 2003-11-02 22:16:34
Message-ID: 20031102141232.P85650@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 31 Oct 2003, Neil Zanella wrote:

> Hello,
>
> I would like to ask the about the following...
>
> PostgreSQL allows tables resulting from subselects to be renamed with
> an optional AS keyword whereas Oracle 9 will report an error whenever
> a table is renamed with the AS keyword. Furthermore, in PostgreSQL
> when the result of a subselect is referenced in an outer select
> it is required that the subselect result be named, whereas this
> is not true in Oracle. I wonder what standard SQL has to say
> about these two issues. In particular:
>
> 1. Does standard SQL allow an optional AS keyword for (re/)naming
> tables including those resulting from subselects.
>
> and
>
> 2 Why must a subselect whose fields are referenced in an outer query
> be explicitly named in PostgreSQL when it is not necessary in Oracle.

I believe the section in question of SQL92 that you're asking about
says explicitly that a table reference from a derived table should look
like:
<derived table> [ AS ] <correlation name> [ <left paren> <derived column
list> <right paren> ]
where <derived table> is a table subquery.

It's possible that SQL99 changes this, but in SQL92 at least, it looks
like the correlation name is not optional (although the AS keyword is).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-11-02 22:22:48 Re: PostgreSQL License Question
Previous Message Tom Lane 2003-11-02 21:34:16 Re: AS operator and subselect result names: PostgreSQL vs. Oracle