Re: Alter column

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Mike Ellsworth <nhrcommu(at)rochester(dot)rr(dot)com>
Cc: Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Alter column
Date: 2006-08-14 12:12:33
Message-ID: 20060814121232.GA62876@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-08-14 12:17:58 Re: Alter column
Previous Message Christoph Frick 2006-08-14 12:06:33 Re: Alter column