Re: Nombres de columna duplicados

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: Oswaldo Hernández <listas(at)soft-com(dot)es>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Nombres de columna duplicados
Date: 2008-01-27 01:31:01
Message-ID: c2d9e70e0801261731h74aa854ej8ef2a5b0645d5f31@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On Jan 25, 2008 2:12 PM, Oswaldo Hernández <listas(at)soft-com(dot)es> wrote:
> Hola a todos,
>
> Acabo de darme cuenta que Postgres no da error si hay nombres de columna duplicados.
> ¿Es un bug?
>
> postgres=# select 1 as a, 2 as a, 3 as a;
> a | a | a
> ---+---+---
> 1 | 2 | 3
> (1 fila)
>
>

No. Así esta definido el estándar SQL. En SQL92 (la verdad me dio
pereza revisar en SQL99 y SQL2003, pero creo que en ese punto no
cambia) puedes ver en el punto 7.9 <query specification> donde el
punto 9 dice (fijate en la clausula a):

9) Case:

a) If the i-th <derived column> in the <select list> specifies
an <as clause> that contains a <column name> C, then the
<column name> of the i-th column of the result is C.

b) If the i-th <derived column> in the <select list> does not
specify an <as clause> and the <value expression> of that
<derived column> is a single <column reference>, then the
<column name> of the i-th column of the result is C.

c) Otherwise, the <column name> of the i-th column of the <query
specification> is implementation-dependent and different
from the <column name> of any column, other than itself, of
a table referenced by any <table reference> contained in the
SQL-statement.

--
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2008-01-27 01:35:11 Re: Obtener lista de tablas de base de datos en postgresql
Previous Message Luis German Torres M 2008-01-27 00:45:47 Re: Obtener lista de tablas de base de datos en postgresql