Re: Adding a New Column Specifically In a Table

From: Thom Brown <thom(at)linux(dot)com>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding a New Column Specifically In a Table
Date: 2010-10-13 22:18:07
Message-ID: AANLkTinzBBBCF3MH2roy554jUxGTdDh9_AebEkHW90AY@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 13 October 2010 19:04, 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;
>
> The above command dumps the 'employer' column at the very end of my
> table which is not what I want.
>
> Thanks for any assistance...

You cannot place a column before any existing column. Why is that
important? You can select the columns in any order you wish in
queries. And even if you had the ability to specify placement of a
column before another column, its unlikely it would physically rewrite
the column data to match that, so the column position would only be
cosmetic.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2010-10-13 22:19:29 Re: Adding a New Column Specifically In a Table
Previous Message Osvaldo Kussama 2010-10-13 21:19:13 Re: How to search ignoring spaces and minus signs