Re: pg_attribute.attnum - wrong column ordinal?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Konstantin Izmailov <pgfizm(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_attribute.attnum - wrong column ordinal?
Date: 2009-12-03 13:42:39
Message-ID: 20091203134239.GB5059@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Greg Stark escribió:
> On Wed, Nov 25, 2009 at 1:03 AM, Konstantin Izmailov <pgfizm(at)gmail(dot)com> wrote:
>
> > My question: can pg_attribute.attnum be used to determine the sequential
> > ordinal positions of columns in a table? What is a right way to get the
> > ordinal numbers?
>
> You could use something like:
>
> row_number() over (partition by T.schemaname,T.viewname order by
> attnum) as "ORDINAL_POSITION"

Should we recast the attributes and columns views in information_schema?
I notice they still use attnum.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-12-03 13:44:32 Re: Catastrophic changes to PostgreSQL 8.4
Previous Message Greg Stark 2009-12-03 13:41:18 Re: Catastrophic changes to PostgreSQL 8.4

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-12-03 13:44:32 Re: Catastrophic changes to PostgreSQL 8.4
Previous Message Greg Stark 2009-12-03 13:41:18 Re: Catastrophic changes to PostgreSQL 8.4