Re: Mapping/DB Migration tool

From: Reece Hart <reece(at)harts(dot)net>
To: MC Moisei <mcmoisei(at)hotmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Mapping/DB Migration tool
Date: 2006-07-25 23:23:39
Message-ID: 1153869819.30183.91.camel@tallac.gene.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)csb-dev=> create table timely (quand date);
CREATE TABLE
Time: 14.385 ms
rkh(at)csb-dev=> insert into timely values ('1968-11-22');
INSERT 0 1
Time: 2.398 ms
rkh(at)csb-dev=> insert into timely values (now());
INSERT 0 1
Time: 4.683 ms
rkh(at)csb-dev=> select * from timely ;
quand
------------
1968-11-22
2006-07-25
(2 rows)

Time: 2.263 ms
rkh(at)csb-dev=> alter table timely alter column quand type timestamp;
ALTER TABLE
Time: 39.002 ms
rkh(at)csb-dev=> select * from timely ;
quand
---------------------
1968-11-22 00:00:00
2006-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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2006-07-25 23:31:58 Re: Executing an SQL query from an internal function...
Previous Message Redefined Horizons 2006-07-25 22:44:54 Executing an SQL query from an internal function...