Re: Unable To Change Data Type

From: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unable To Change Data Type
Date: 2011-06-10 18:02:26
Message-ID: BANLkTimyKV0udHVOxg5pUdEp9bs8TXWZTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 10, 2011 at 1:57 PM, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:
> I don't think ALTER COLUMN TYPE will implicitly convert from varchar
> to INT.
>
> Try:
> ALTER TABLE reference
>  ALTER COLUMN color
>    TYPE INT
>    USING CAST(color AS INT);

Your command suggestion worked perfect but can you explain why yours
worked and mine didn't? I've never used 'USING CAST' command before.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2011-06-10 18:18:19 Re: Unable To Change Data Type
Previous Message Andreas Kretschmer 2011-06-10 18:01:00 Re: Unable To Change Data Type