Re: Converting varchar() to text

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Steve Atkins <steve(at)blighty(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Converting varchar() to text
Date: 2004-09-17 06:47:04
Message-ID: 200409170247.04485.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 15 September 2004 12:29, Steve Atkins wrote:
> Is there a safe way to convert varchar(n) to text, other than create
> a new column, update, delete column, rename?
>
> I have a number of databases that were built with varvhar(n) and which
> should have been done with text. They're in production, and I'd rather
> not take the downtime needed to convert some rather large tables - the
> bulk update hitting every row of the large table makes it effectively
> unvacuumable, and vacuum full requires locks that effectively shut
> down the entire system.
>
> They're the same format on disk, so I'm guessing that some diddling
> with pg_attribute may be possible. Does anyone have any experience
> doing this?
>

I wouldn't say it's impossible to do it, but several people have reported
corruption issues in things like indexes when doing this type of thing in
7.4.x. If you really cant do it the normal way, if you dont have too many
trigger issues, is to create a new table via a select statement with the
proper columns, then drop the old table and rename the new one. Another idea
might be to just add the new column and then use a view with some coalesce
magic to combine the two columns into one. HTH

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Katsaros Kwn/nos 2004-09-17 07:26:31 Re: Is it possible to get the 7.4.1 static docs in HTML
Previous Message Pierre-Frédéric Caillaud 2004-09-17 06:42:03 Re: UTF-8 question.