Re: change column data type from smallint to integer

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: "pobox(at)verysmall(dot)org" <pobox(at)verysmall(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: change column data type from smallint to integer
Date: 2005-09-08 02:50:39
Message-ID: 20050908025039.GA11222@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 08, 2005 at 04:22:07AM +0200, pobox(at)verysmall(dot)org wrote:

Hi,

> we run 'out of space' in one of our columns which is smallint and we
> need to make it integer.
>
> I did some research and found out that the only way is to create a new
> column with integer data type, then SET new = old, then drop old and
> rename new like old [1].
>
> Could somebody confirm if this is really the best way and if it is
> stable in respect to indexes, RI, triggers, stored procedures, etc.

In 8.0, you can alter the type directly in the table. In releases
before 8.0, you have found the right workaround.

--
Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com
"Crear es tan difícil como ser libre" (Elsa Triolet)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-09-08 02:57:53 Re: back references using regex
Previous Message Leonid Safronie 2005-09-08 02:45:33 Cost based SELECT/UPDATE