Re: Altering a table - positioning new columns

From: Tim Frank <tfrank(at)registrar(dot)uoguelph(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Altering a table - positioning new columns
Date: 2003-01-20 18:02:37
Message-ID: b0hdjs$2oci$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2003-01-20 18:02:57 Re: readline configure error again
Previous Message Justin Clift 2003-01-20 17:52:49 Re: Database Performance problem