Re: Column order

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "Vyacheslav Kalinin" <vka(at)mgcp(dot)com>
Subject: Re: Column order
Date: 2008-04-24 01:49:26
Message-ID: 200804232149.26464.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 23 April 2008 21:33, Vyacheslav Kalinin wrote:
> Hello,
>
> It is often convenient to have columns of a table in certain order (as
> shown by psql or most GUI database explorers, it also affects INSERT's
> without columns specified behavior) so as to most significant columns
> to
> come first, semantically close columns to be grouped etc, while the columns
> might be added to the table in different order during development
> process. So, the question is - is it an acceptable way to play with
> pg_attribute's attnum and set it to needed value
> or recreate the table is the only
> way? On the related note - should the columns necessarily be numbered
> from 1 up with the step of 1?
>

If you do this on a table with data in it you will almost certainly hoark your
data. On an empty table I'd just expect things to break. If you are really
interested in being able to re-order columns, search the archives for a patch
we saw ~ year or so ago that implemented storage level column ordering. The
discussion that followed laid out much of what would also be needed for
logical level column sorting. Work out those two bits and you'll have soon
have a patch for doing this the right way.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

In response to

  • Column order at 2008-04-24 01:33:21 from Vyacheslav Kalinin

Browse pgsql-general by date

  From Date Subject
Next Message Andrej Ricnik-Bay 2008-04-24 02:39:28 Re: Stored procedures in C
Previous Message Vyacheslav Kalinin 2008-04-24 01:33:21 Column order