Re: How to change data type in column ?

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Vitali Djatsuk" <Vitali(dot)Djatsuk(at)MicroLink(dot)ee>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to change data type in column ?
Date: 2003-04-15 10:14:18
Message-ID: 200304151114.19157.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 15 Apr 2003 10:36 am, Vitali Djatsuk wrote:
> Hi,
>
> How can I change a data type in column ?

Well, the closest you could get would be something like:

ALTER TABLE RENAME column TO backup_column;
ALTER TABLE ADD COLUMN column ...;
...copy and transform data...
ALTER TABLE DROP COLUMN backup_column;

Personally, I tend to dump/recreate the table where possible, but I might be a
little paranoid there.
I think you'll need to recreate any triggers/FK's in either case.
--
Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2003-04-15 10:16:12 Re: Two 'identical' DB's not acting identically
Previous Message Wayne Armstrong 2003-04-15 10:10:48 Re: Are we losing momentum?