Re: Adding a New Column Specifically In a Table

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Adding a New Column Specifically In a Table
Date: 2010-10-14 02:28:39
Message-ID: 482E80323A35A54498B8B70FF2B87980047B12D628@azsmsx504.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think it's incorrect to expect a query to return column in any specific order if you do something like "select * from...". You may see columns returned in the order you created them, but I don't believe it's guaranteed. If you want a specific order, then.... "select col1, col3, col5, col2, ...".

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Carlos Mennens
Sent: Wednesday, October 13, 2010 2:07 PM
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Adding a New Column Specifically In a Table

On Wed, Oct 13, 2010 at 2:04 PM, Carlos Mennens
<carlos(dot)mennens(at)gmail(dot)com> wrote:
> OK so I have read the docs and Google to try and find a way to add a
> new column to an existing table. My problem is I need this new column
> to be created 3rd  rather than just dumping this new column to the end
> of my table. I can't find anywhere how I can insert my new column as
> the 3rd table column rather than the last (seventh). Does anyone know
> how I can accomplish this or if it's even possible. Seems like a
> common task but I checked the documentation and may have missed it in
> my reading.
>
>
> ALTER TABLE users ADD COLUMN employer VARCHAR(50) NOT NULL;

Ah sadly I just found this after I pressed 'send' and realized
PostgreSQL doesn't support it...that sucks :(

http://wiki.postgresql.org/wiki/Alter_column_position

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua Berry 2010-10-14 02:41:38 Re: How to search ignoring spaces and minus signs
Previous Message Grzegorz Jaśkiewicz 2010-10-14 01:35:15 Re: How to search ignoring spaces and minus signs