Thread: BUG #5573: How can i add field inbetween in the table while creating

The following bug has been logged online:

Bug reference:      5573
Logged by:          Vimi
Email address:      vimmipraj@gmail.com
PostgreSQL version: Ver 8.4.1
Operating system:   Windows 7
Description:        How can i add field inbetween in the table while
creating
Details:

If i have already crreated one table and i wan to add one more field into
table but its ibetween imean if i have 4 fields are already created and if i
want to add one more field aat 2nd index then how can i do in postgre. i
tried in Navicat but no luck.


Do you have any suggestion?

Thanks in adv.

Re: BUG #5573: How can i add field inbetween in the table while creating

From
Joshua Tolley
Date:
On Tue, Jul 27, 2010 at 07:34:56AM +0000, Vimi wrote:
> If i have already crreated one table and i wan to add one more field into
> table but its ibetween imean if i have 4 fields are already created and if i
> want to add one more field aat 2nd index then how can i do in postgre. i
> tried in Navicat but no luck.

You can't change column order without dropping and recreating the columns,
recreating the table, or something similar. Sorry.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Re: BUG #5573: How can i add field inbetween in the table while creating

From
"Kevin Grittner"
Date:
"Vimi" <vimmipraj@gmail.com> wrote:

> How can i add field inbetween in the table while creating

This is not a bug; in the future please post such questions to
pgsql-general.

While the feature you're requesting is likely to appear in a future
release, current releases require that you create a new table with
the desired structure, copy data from the old table into it, drop or
rename the old table, and rename the new table into place.  You
would probably want to begin a transaction and acquire an exclusive
lock on the old table before starting this, and commit after the new
table is in its place.

On the other hand, in well-written software, the order of the
columns in the table should make no difference; you might just want
to avoid SELECT * and dodge the whole issue.

-Kevin