Re: Unable To Change Data Type

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Unable To Change Data Type
Date: 2011-06-10 18:26:04
Message-ID: 4DF261BC.7080006@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/10/11 11:02 AM, Carlos Mennens wrote:
> 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.
>

pgsql <= 8.3 was lax about char->other casting. due to some discovered
ambiguities, it was tightened up in 8.4+

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-06-10 19:05:28 Re: duplicate postings
Previous Message Bill Moran 2011-06-10 18:18:19 Re: Unable To Change Data Type