Change attribute type

Поиск
Список
Период
Сортировка
От Petter Reinholdtsen
Тема Change attribute type
Дата
Msg-id 199807161557.RAA28247@sleeper.games.no
обсуждение исходный текст
Ответы Re: [SQL] Change attribute type  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Список 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 по дате отправления:

Предыдущее
От: "Ounnapirak, Chotiwat"
Дата:
Сообщение: RE: pgsql-sql-digest V1 #9
Следующее
От: Danny Rice
Дата:
Сообщение: data larger than 8k