Re: Change order of table-columns in pg_catalog.pg_attribute.attnum

From: "Igor Neyman" <ineyman(at)perceptron(dot)com>
To: "Erwin Brandstetter" <brsaweda(at)gmail(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Change order of table-columns in pg_catalog.pg_attribute.attnum
Date: 2007-06-06 15:50:52
Message-ID: F4C27E77F7A33E4CA98C19A9DC6722A201F76CE1@EXCHANGE.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

More important question would be, why would you want to do this (change columns order)?
I can't think of any valid reason for this.

Igor Neyman

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org [mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Erwin Brandstetter
Sent: Wednesday, June 06, 2007 11:22 AM
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] Change order of table-columns in pg_catalog.pg_attribute.attnum

On Jun 6, 4:59 pm, t(dot)(dot)(dot)(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote:
> Alvaro Herrera <alvhe(dot)(dot)(dot)(at)commandprompt(dot)com> writes:
> > Erwin Brandstetter escribió:
> >> If I want to change the default order of two columns of a table,
> >> can I just manipulate the values in pg_catalog.pg_attribute.attnum?
> > It works -- as long as the table is empty.
>
> And as long as you have no views, foreign keys, indexes, defaults,
> rules, etc etc etc referencing the columns.
>
> Short answer is don't even think of trying it.

Thanks for your answers.
I had tried it with data in the table and it seemed to work, but it does mess up views referencing the table. So, no go.

The only way to change the default order of columns is still to drop the table and all references to it and recreate it all?

Regards
Erwin

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Chris Hoover 2007-06-06 18:12:12 8.2.4 Won't Build 8.1 Functional Indexes
Previous Message Erwin Brandstetter 2007-06-06 15:48:35 Re: get the array content whis the select clause