Re: Mapping/DB Migration tool

Поиск
Список
Период
Сортировка
От Reece Hart
Тема Re: Mapping/DB Migration tool
Дата
Msg-id 1153869819.30183.91.camel@tallac.gene.com
обсуждение исходный текст
Ответ на Re: Mapping/DB Migration tool  ("MC Moisei" <mcmoisei@hotmail.com>)
Список pgsql-general
On Tue, 2006-07-25 at 17:21 -0500, MC Moisei wrote:
The main thing is I changed a bunch of date types to timestamp type. Is
there a simple way to change the type on such fields ?

Yes, and more generally to change the type of a column. See below:

rkh@csb-dev=> create table timely (quand date);
CREATE TABLE
Time: 14.385 ms
rkh@csb-dev=> insert into timely values ('1968-11-22');
INSERT 0 1
Time: 2.398 ms
rkh@csb-dev=> insert into timely values (now());
INSERT 0 1
Time: 4.683 ms
rkh@csb-dev=> select * from timely ;
   quand
------------1968-11-222006-07-25
(2 rows)

Time: 2.263 ms
rkh@csb-dev=> alter table timely alter column quand type timestamp;
ALTER TABLE
Time: 39.002 ms
rkh@csb-dev=> select * from timely ;
        quand
---------------------1968-11-22 00:00:002006-07-25 00:00:00
(2 rows)

Time: 1.457 ms


Similarly, try 'alter table timely rename column quand to cuando' .

Also: \h alter table

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

В списке pgsql-general по дате отправления:

Предыдущее
От: "Redefined Horizons"
Дата:
Сообщение: Executing an SQL query from an internal function...
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Executing an SQL query from an internal function...