From: | Petter Reinholdtsen <pere(at)hungry(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Change attribute type |
Date: | 1998-07-16 15:57:06 |
Message-ID: | 199807161557.RAA28247@sleeper.games.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)td(dot)org(dot)uit(dot)no
O- <SCRIPT Language="Javascript">window.close()</SCRIPT>
http://www.hungry.com/~pere/ | Go Mozilla, go! Go!
From | Date | Subject | |
---|---|---|---|
Next Message | Danny Rice | 1998-07-16 16:40:18 | data larger than 8k |
Previous Message | Ounnapirak, Chotiwat | 1998-07-16 02:46:40 | RE: pgsql-sql-digest V1 #9 |