From: | Bill Moran <wmoran(at)potentialtech(dot)com> |
---|---|
To: | Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Unable To Change Data Type |
Date: | 2011-06-10 18:18:19 |
Message-ID: | 20110610141819.523bec6b.wmoran@potentialtech.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
In response to Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>:
> 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.
Apparently, PostgreSQL isn't sure of how to do the conversion, so you
have to tell it. You could just as easily given any valid expression
to the USING clause -- if your conversion was more complex than simply
a cast.
--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2011-06-10 18:26:04 | Re: Unable To Change Data Type |
Previous Message | Carlos Mennens | 2011-06-10 18:02:26 | Re: Unable To Change Data Type |