Re: Altering a table - positioning new columns - Mailing list pgsql-general

From Tim Frank
Subject Re: Altering a table - positioning new columns
Date
Msg-id b0hdjs$2oci$1@news.hub.org
Whole thread Raw
In response to Re: Altering a table - positioning new columns  ("Chris Boget" <chris@wild.net>)
List pgsql-general
Chris,

See comments inline below,

>>No.  Sorry.
>
>
> *sigh*  That kind of bites.
> I'm curious how difficult this would be to implement...
>
>
>> If column order is important, you have to create a new table and copy
>>over the data, then drop the old table and rename the new one.
>

Sorry to jump in the middle as I may have lost a bit of what you are
trying to accomplish, but if you are merely worried about how the
columns are grouped visually you could set up views and have them appear
in any order you want.  You can go as far as making the view updatable
as well, but that would really be no different than updating/inserting
into the table.

>
> Yeah, that's what I've been doing all weekend.
>
>
>>Of course this has its drawbacks, if there are triggers, foreign keys, ...
>
>
> Yeah, these are pretty serious drawbacks.  It took me 30+ minutes to do
> this for just _one_ table.  I don't like new fields trailing the column list because
> I prefer all similar columns to be grouped.  That way if you are viewing the
> data through a UI, it's easier to see/read.
> But I guess unless I want to spend hours adding a few columns to some
> tables, I'm just going to have to learn to live with it... :|
>

I use to get hung up on the table layout, but now I do my best to group
things as well as I can at the time it is created, and if more columns
are needed in the future, I either recreate the entire structure or live
with the "out of order" columns.  In the end when you are inserting with
the field/value list it doesn't matter anyways.

So, views can be your friend when you require a certain "view" of your
data ;)

Tim


pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: Re: Database Performance problem
Next
From: Andrew Sullivan
Date:
Subject: Re: readline configure error again