Re: Mapping/DB Migration tool - Mailing list pgsql-general

From Reece Hart
Subject Re: Mapping/DB Migration tool
Date
Msg-id 1153869819.30183.91.camel@tallac.gene.com
Whole thread Raw
In response to Re: Mapping/DB Migration tool  ("MC Moisei" <mcmoisei@hotmail.com>)
List 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 by date:

Previous
From: "Redefined Horizons"
Date:
Subject: Executing an SQL query from an internal function...
Next
From: Alvaro Herrera
Date:
Subject: Re: Executing an SQL query from an internal function...