Change attribute type - Mailing list pgsql-sql

From Petter Reinholdtsen
Subject Change attribute type
Date
Msg-id 199807161557.RAA28247@sleeper.games.no
Whole thread Raw
Responses Re: [SQL] Change attribute type  (Herouth Maoz <herouth@oumail.openu.ac.il>)
List pgsql-sql
How do I change an attributes type, or how do I remove an attribute
from a table.

I have a table created with this command:

  create table test(data int4, changed timestamp);

I want to have this table instead:

  create table test(data int4, changed datetime);

I have lots of entries in the table, and want too keep them when I
change the date type.

The simple method would be to change the type.  Is it possible?

The hard method requires the possibility of removing an attribute.

 1 change name of the attribute
   'alter table test rename column changed to changedold;'
 2 create new attribute
   'alter table test add changed datetime;'
 3 insert old data in new attribute
   'update test set changed = changedold;'
 4 remove the old attribute
   ?

Any clues?

BTW: As I don't follow this mailing-list, could you please send me a
copy when replying?
--
##>  Petter Reinholdtsen <##    | pere@td.org.uit.no
 O-  <SCRIPT Language="Javascript">window.close()</SCRIPT>
http://www.hungry.com/~pere/    | Go Mozilla, go! Go!

pgsql-sql by date:

Previous
From: "Ounnapirak, Chotiwat"
Date:
Subject: RE: pgsql-sql-digest V1 #9
Next
From: Danny Rice
Date:
Subject: data larger than 8k