From: | "Stewart Ben (RBAU/EQS4) *" <Ben(dot)Stewart(at)au(dot)bosch(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: changing a column's position in table, how do you do that |
Date: | 2005-09-28 00:25:04 |
Message-ID: | E253BDD7F008244585AEE87AF8F0224F116C7A74@cl-mail01.au.bosch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Ferindo,
> Is there a way to change the position attribute of a column
> in a table?
AFAIK, there's no way to change this easily. The best way to do it would
be as follows:
BEGIN WORK;
LOCK TABLE mytable IN ACCESS EXCLUSIVE MODE;
ALTER TABLE mytable ADD COLUMN col_to_move_2 coltype;
UPDATE mytable SET col_to_move_2 = col_to_move;
ALTER TABLE mytable DROP COLUMN col_to_move;
ALTER TABLE mytable RENAME col_to_move_2 TO col_to_move;
COMMIT WORK;
Best regards,
Ben Stewart
--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Student Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
mailto:ben(dot)stewart(at)au(dot)bosch(dot)com
http://www.bosch.com.au/
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Browne | 2005-09-28 03:24:13 | Re: changing a column's position in table, how do you do that |
Previous Message | Ferindo Middleton Jr | 2005-09-27 22:52:11 | changing a column's position in table, how do you do that |