Re: alter table, placing the new column after the id

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Zouari Fourat <fourat(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: alter table, placing the new column after the id
Date: 2006-02-28 19:18:38
Message-ID: C02A0C3E.70B3%sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

You can't, I don't think. You could copy the old table to a new table using

insert into .... Select ....

And then rename the new table to the old. Alternatively, you could specify
a view with the columns in the correct order.

Sean

On 2/28/06 2:13 PM, "Zouari Fourat" <fourat(at)gmail(dot)com> wrote:

> Hello,
> When trying to alter my table to add a column, it will be added at the
> end of the table, i want to get my column after a given column name,
> for example get my table like this :
>
> ID
> firstname
> lastname
> <--- my new added column here
> adrress
> country
> <--- not here !
>
> how to get it ?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-02-28 19:41:23 Re: install
Previous Message Zouari Fourat 2006-02-28 19:13:03 alter table, placing the new column after the id