Skip site navigation (1) Skip section navigation (2)

Re: alter table add column - specify where the column will go?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stuart McGraw <smcg2297(at)frii(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: alter table add column - specify where the column will go?
Date: 2010-11-24 17:51:47
Message-ID: 26398.1290621107@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Stuart McGraw <smcg2297(at)frii(dot)com> writes:
> This is the first time I've ever looked at the 1000+ page spec and I 
> haven't tried to chase down all the definitions so I don't pretend to
> be authoritative but it sure sounds to me (as your observation above 
> implies) that SQL *does* have an explicit notion of column order.

Yes, it does.  If it did not, they would never have provided the option
of omitting the target-column-name list from INSERT.

As for the original issue, the ability to add a column somewhere other
than at the end is on the TODO list, but it's been there for quite some
time so don't hold your breath waiting for it to get done.  There are
several discussions in the pgsql-hackers archives about why it isn't
a simple thing to do.

In the meantime, if the OP wants it bad enough he can do something
involving CREATE TABLE ... AS SELECT ... to build a new table with
the columns in the desired order, and then rename it to replace the
old table.

			regards, tom lane

In response to

pgsql-general by date

Next:From: DMDate: 2010-11-24 17:52:41
Subject: Postgres 9.01 and WAL files issue
Previous:From: Mark Morgan LloydDate: 2010-11-24 17:38:51
Subject: Re: Getting current and average on a single row

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group