[lug] Postgres Alter table

rm at mamma.varadinet.de rm at mamma.varadinet.de
Fri Jul 13 02:27:35 MDT 2001


On Thu, Jul 12, 2001 at 09:51:43PM -0600, Ryan Kirkpatrick wrote:
> 	This would be even easier if you could drop a column. Instead of
> selecting out the entire table, select out just the column you want to
> convert. Then alter the table to drop the column and then recreate. After
> that load the data back in. One would have to be careful about order,
> maybe pull out a key field along with it.
> 	Though PGSQL does not yet support dropping a column from a table,
> but if I remember correctly, it is on the TODO list.

Hmm, as far as i understand the storage manager of postgresql this doesn't
seem trivial. Taken the fact that altering the data type of a column hope-
fully happens rather seldom i can easily live without it. 

> 	This is not that much of a worry. Indices will be automatically
> dropped along with the table when it is dropped. So you only need to
> recreate them (probably from the original scheme you used to build the
> table in the first place). Same story for constraints. Views probably will
> not be dropped with the table and will have to be reconstructed. Only
> other worries is if you have sequences assocaited with the table (in which
> case handle them like views, though remember to restore their 'next'
> value), and foriegn key relationships.

You're right, indices and constraints will be dropped (but not recreated).
What about triggers and rules? (i never checked this).

 Ralf



More information about the LUG mailing list