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

From Tino Wildenhain
Subject Re: Alter field type?
Date
Msg-id 1093509108.1520.36.camel@Andrea.peacock.de
Whole thread Raw
In response to Alter field type?  (Bjørn T Johansen <btj@havleik.no>)
Responses Re: Alter field type?  (Bjørn T Johansen <btj@havleik.no>)
List pgsql-general
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


pgsql-general by date:

Previous
From: "gnari"
Date:
Subject: Re: Possible to insert quoted null value into integer field?
Next
From: Greg Stark
Date:
Subject: Re: Alter field type?