Re: How to convert a binary filed to an integer field? - Mailing list pgsql-general

From Merlin Moncure
Subject Re: How to convert a binary filed to an integer field?
Date
Msg-id AANLkTimLbGHC+mBRYjtWtb0tUCrkYCfy=ksLni4DQ8je@mail.gmail.com
Whole thread Raw
In response to Re: How to convert a binary filed to an integer field?  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On Thu, Aug 26, 2010 at 1:47 PM,  <wei725@lycos.com> wrote:
> I know what I need to do in the application for the change. My problem is that I don't know a good process to make a
suchchange in PostgreSQL. Since the application is in production already, do I need to create another field or convert
thedata from the boolean field into the new field? 

recent versions of postgres allow you to do transformations w/alter table:

alter table foo alter bool_col type text using case when bool_col then
'foo' else 'bar' end;

expression can hook to a function if you want to do something really
complex (yes this is awesome) :-)

merlin

pgsql-general by date:

Previous
From: Matthieu HUIN
Date:
Subject: Re: Weird behavior with custom operators
Next
From: wei725@lycos.com
Date:
Subject: Re: How to convert a binary filed to an integer field?