Re: Modyifying a column's datatype - Mailing list pgsql-novice

From Ron Johnson
Subject Re: Modyifying a column's datatype
Date
Msg-id 1062623588.7341.411.camel@haggis
Whole thread Raw
In response to Modyifying a column's datatype  ("Louise Cofield" <lcofield@box-works.com>)
Responses Re: Modyifying a column's datatype  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
Re: Modyifying a column's datatype  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-novice
On Wed, 2003-09-03 at 14:56, Louise Cofield wrote:
> Greetings –
>
>
>
> It looks to me as if there is no way to alter the datatype of a table
> column, as in from timestamp to varchar.  Am I right?  (I will cry if
> I’m right.) L.
>
> It appears that I must drop and then re-create the table structure,
> with my new column datatype,  in order to keep the columns in the
> current order – true?

There are references to this all throughout the archives.

begin;
alter table foo add column bar varchar;
update foo set bar = cast(sniffle as varchar);
alter table foo drop column sniffle;
alter table foo rename column bar to sniffle;
commit;

--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA

PETA - People Eating Tasty Animals


pgsql-novice by date:

Previous
From: "Girish Bajaj"
Date:
Subject: Lock and read next
Next
From: Jeff Eckermann
Date:
Subject: Re: Modyifying a column's datatype