Skip site navigation (1) Skip section navigation (2)

Re: Alter field type?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Bjørn T Johansen <btj(at)havleik(dot)no>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Alter field type?
Date: 2004-08-26 08:31:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

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.

Tino Wildenhain

In response to


pgsql-general by date

Next:From: Greg StarkDate: 2004-08-26 08:36:18
Subject: Re: Alter field type?
Previous:From: gnariDate: 2004-08-26 08:27:59
Subject: Re: Possible to insert quoted null value into integer field?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group