I posted this in my last message, but have not heard anything yet so I'm
wondering if it was overlooked.  I need to know how to change a column from
being say a varchar(9) to an integer.  Does anyone know how to change the
data type?

Geoff

Mon, 24 Sep 2001 10:18:34 -0400
"Gowey, Geoffrey" <ggowey@rxhope.com>
Changing data types
This is not for -hackers. 

And the answer is "no, you can't". Recreate the table with correct types
and insert the old values into it.

On Mon, 24 Sep 2001, Gowey, Geoffrey wrote:

> I posted this in my last message, but have not heard anything yet so I'm
> wondering if it was overlooked.  I need to know how to change a column from
> being say a varchar(9) to an integer.  Does anyone know how to change the
> data type?
> 
> Geoff
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 
> 


Mon, 24 Sep 2001 10:40:23 -0400 (EDT)
Alex Pilosov <alex@pilosoft.com>
Re: Changing data types
"Gowey, Geoffrey" wrote:
> 
> I posted this in my last message, but have not heard anything yet so I'm
> wondering if it was overlooked.  I need to know how to change a column from
> being say a varchar(9) to an integer.  Does anyone know how to change the
> data type?

create temptable
 as select col_a, col_b, varchar9col_c::int, col_d from originaltable
;

drop table originaltable;

alter table temptable rename to originaltable;



and then create all indexes and constraints.

---------------
Hannu

Mon, 24 Sep 2001 17:03:38 +0200
Hannu Krosing <hannu@tm.ee>
Re: Changing data types