alter varchar() column length?

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: alter varchar() column length?
Date: 2008-01-11 14:55:57
Message-ID: D7FF158337303A419CF4A183F48302D60394D0FA@hdsmsx411.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there a way to alter a varchar column's length? Maybe something like
"alter table foo alter column xyz varchar(256)".

My alternative seems very messy...

- alter table, add a new column with the desired varchar
length. call it "temp"

- insert into "temp" the value of the old column.

- alter table, drop the old column (messing up all the indexes
on that column in the process I suppose)

- alter table, add a new column with the same name as the one
you just deleted, only with the desired length

- insert into that new column the value in "temp"

- alter table, drop "temp"

- recreate all the indexes

Thanks

-dave

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2008-01-11 15:10:03 Re: alter varchar() column length?
Previous Message Clodoaldo 2008-01-11 14:24:06 Re: ATTN: Clodaldo was Performance problem. Could it be related to 8.3-beta4?