From: Olivier Gautherot <ogautherot@gautherot.net>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Wells Oliver <wells.oliver@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Re-order columns?
Date: Wed, 29 Jul 2020 23:10:29 +0200
Message-ID: <CAJ7S9TUGYeDNECfv1MJ-92REXBTiO2siQnPujU1qE-uN1NOsaQ@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwYQbDVoKMT=Eem92F0xitXNgM_iCDMtzjChyT3pAi9N5w@mail.gmail.com>
References: <CAOC+FBUm=b0a2j0h=qDSCqVwO8yWm2fgYSwH2=StVsia4eYLMQ@mail.gmail.com>
<CAKFQuwYQbDVoKMT=Eem92F0xitXNgM_iCDMtzjChyT3pAi9N5w@mail.gmail.com>
Hi,
On Wed, Jul 29, 2020 at 10:45 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:
> On Wednesday, July 29, 2020, Wells Oliver <wells.oliver@gmail.com> wrote:
>
>> I know this kind of dumb, but is there a way to re-order columns? You
>> know, you have your awesome table all defined, your favorite modified_at
>> column at the end where you like it, then some guy comes along and is like
>> "oh let's add X Y and Z" and your OCD really really really wants the
>> modified_at col at the end, and blowing away/re-populating the table takes
>> way too long
>>
>
> There is not. Every so often this gets looked at but has yet to result in
> a commit.
>
It is an issue that pops up regularly and there are technical issues
behind. It has been fixed in other engines but not yet here.
If it is critical for your application, I could suggest 2 ways:
1) run a SELECT INTO taking care of the proper column order everytime you
ALTER the table (it may or may not be doable depending on your specific
case)
2) place a view in front of the table with the expected order
The latter will surely reduce the maintenance, overhead, downtime... Now if
the order is really critical, you should probably specify the columns list
when you access the table (knowing it can be a pain if there are many).
Note that if it gets solved, it will most probably be done in the catalog
and not the table itself.
Hope it helps
Olivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: ogautherot@gautherot.net, david.g.johnston@gmail.com, wells.oliver@gmail.com
Subject: Re: Re-order columns?
In-Reply-To: <CAJ7S9TUGYeDNECfv1MJ-92REXBTiO2siQnPujU1qE-uN1NOsaQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox