R: Field's position in Table

From: Scara Maccai <m_lists(at)yahoo(dot)it>
To: pgsql-general(at)postgresql(dot)org, Kalai R <softlinne(dot)kv(at)gmail(dot)com>
Subject: R: Field's position in Table
Date: 2009-08-20 09:21:25
Message-ID: 310458.51343.qm@web24616.mail.ird.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> When adding a new field in the existing table, i
> want to add the filed in a particular position.

I'm afraid the only way would be re-writing the whole table (pseudo sql):

BEGIN;
create table newtable as select field1, 'newfield default value', field2 from old_table;
create_all_indexes on newtable;
drop old_table;
commit;

things get complicated if you have foreign keys pointing to old_table...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message vinny 2009-08-20 09:24:49 Re: R: Field's position in Table
Previous Message John R Pierce 2009-08-20 09:12:23 Re: Field's position in Table