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

Re: Changing data types

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: "Gowey, Geoffrey" <ggowey(at)rxhope(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Changing data types
Date: 2001-09-24 15:03:38
Message-ID: 3BAF4B4A.20250FFE@tm.ee (view raw or flat)
Thread:
Lists: pgsql-hackers
"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

In response to

pgsql-hackers by date

Next:From: Randal L. SchwartzDate: 2001-09-24 15:06:59
Subject: Re: [HACKERS] Tupple statistics function
Previous:From: Gowey, GeoffreyDate: 2001-09-24 14:55:54
Subject: Re: Changing data types

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