From: Petter Reinholdtsen <pere@hungry.com>
To: pgsql-sql@postgresql.org
Subject: Change attribute type
Date: Thu, 16 Jul 1998 17:57:06 +0200
Message-ID: <199807161557.RAA28247@sleeper.games.no> (raw)
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: pere@hungry.com
Subject: Re: Change attribute type
In-Reply-To: <199807161557.RAA28247@sleeper.games.no>
References: <199807161557.RAA28247@sleeper.games.no>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox