Re: Alter column - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Alter column
Date
Msg-id 20060814121232.GA62876@winnie.fuhr.org
Whole thread Raw
In response to Alter column  (Mike Ellsworth <nhrcommu@rochester.rr.com>)
List pgsql-novice
On Mon, Aug 14, 2006 at 08:00:59AM -0400, Mike Ellsworth wrote:
> Is there a way to convert data type `datetime` into an integer

There is no datetime type.  Do you mean timestamp or timestamp with
time zone?

> (unix_timestamp) while doing ALTER COLUMN `column_name` TYPE int4
> USING CAST(`column_name` as integer) ...... something like this?

Is this what you're looking for?

ALTER TABLE foo ALTER COLUMN column_name TYPE integer
  USING extract(epoch FROM column_name);

--
Michael Fuhr

pgsql-novice by date:

Previous
From: Christoph Frick
Date:
Subject: Re: Alter column
Next
From: Tom Lane
Date:
Subject: Re: Alter column