Re: Existencia de columna en tabla

From: "Andres Duque" <raulandresduque(at)hotmail(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Guido Barosio" <gbarosio(at)gmail(dot)com>
Cc: "Eliana Gutierrez" <egp1962(at)yahoo(dot)com(dot)au>, "ayuda postgres" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Existencia de columna en tabla
Date: 2007-01-09 13:20:17
Message-ID: BAY135-DAV4AAF93D316FF551F8D3ABBAB30@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Disculpa Alvaro .. que hace ese 'for 128' ???

Atentamente,

RAUL ANDRES DUQUE
Bogotá, Colombia

----- Original Message -----
From: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
To: "Guido Barosio" <gbarosio(at)gmail(dot)com>
Cc: "Eliana Gutierrez" <egp1962(at)yahoo(dot)com(dot)au>; "ayuda postgres"
<pgsql-es-ayuda(at)postgresql(dot)org>
Sent: Sunday, January 07, 2007 8:41 PM
Subject: Re: [pgsql-es-ayuda] Existencia de columna en tabla

> Guido Barosio escribió:
>
>> SELECT a.attname,
>> pg_catalog.format_type(a.atttypid, a.atttypmod),
>> (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)
>> FROM pg_catalog.pg_attrdef d
>> WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),
>> a.attnotnull, a.attnum
>> FROM pg_catalog.pg_attribute a
>> WHERE a.attrelid = '24588' AND a.attnum > 0 AND NOT a.attisdropped
>> ORDER BY a.attnum
>
> Tambien puedes hacerlo asi, mas facil y te evita la consulta a pg_class:
>
> SELECT a.attname,
> pg_catalog.format_type(a.atttypid, a.atttypmod),
> (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)
> FROM pg_catalog.pg_attrdef d
> WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),
> a.attnotnull, a.attnum
> FROM pg_catalog.pg_attribute a
> WHERE a.attrelid = 'nombre-tabla'::regclass AND a.attnum > 0 AND NOT
> a.attisdropped
> ORDER BY a.attnum
>
> Lo otro es que el motivo para poner pg_attrdef en un subselect y no como
> un JOIN es un misterio ...
>
> --
> Alvaro Herrera
> http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
> ---------------------------(fin del mensaje)---------------------------
> TIP 2: puedes desuscribirte de todas las listas simultáneamente
> (envíe "unregister TuDirecciónDeCorreo" a majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Agustin Casiva 2007-01-09 13:24:03 Like iLike y Genexus
Previous Message Rodrigo Gil Giuliano 2007-01-09 13:07:32 Re: Pregunta!