Re: Alter field type? - Mailing list pgsql-general

From Bjørn T Johansen
Subject Re: Alter field type?
Date
Msg-id 412DB215.30308@havleik.no
Whole thread Raw
In response to Re: Alter field type?  (Tino Wildenhain <tino@wildenhain.de>)
List pgsql-general
That looks like a recipe, thx... :)

BTJ

Tino Wildenhain wrote:
> Hi,
>
> Am Do, den 26.08.2004 schrieb Bjørn T Johansen um 9:48:
>
>>Is it possible to alter field type (from varchar to text) without making
>>a new table?
>
>
> In 8.0 I think.
> Common practice in 7.4.x is:
>
> BEGIN work;
> ALTER TABLE yourtable ADD COLUMN tempcolumn text;
> UPDATE yourtable SET tempcolumn = origcolumn;
> ALTER TABLE yourtable DROP COLUMN origcolumn;
> ALTER TABLE yourtable RENAME tempcolumn TO origcolumn;
> COMMIT work;
>
> Since text and (unlimited) varchar are quite the same,
> you could get away with modifying the system tables.
> But I would not recomment to do so.
>
> Regards
> Tino Wildenhain
>

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen (BSc,MNIF)
Executive Manager
btj@havleik.no            Havleik Consulting
Phone : +47 21 69 15 20        Bjørnebærstien 57
Fax : +47 41 13 09 15        N-1348 Rykkinn
Cellular : +47 926 93 298    http://www.havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange
Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

pgsql-general by date:

Previous
From: Michal Hlavac
Date:
Subject: Stored procedure failure
Next
From: Markus Bertheau
Date:
Subject: Re: Alter field type?