Re: Column order - Mailing list pgsql-general

From Robert Treat
Subject Re: Column order
Date
Msg-id 200804232149.26464.xzilla@users.sourceforge.net
Whole thread Raw
In response to Column order  ("Vyacheslav Kalinin" <vka@mgcp.com>)
List 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

pgsql-general by date:

Previous
From: "Vyacheslav Kalinin"
Date:
Subject: Column order
Next
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: Stored procedures in C