Re: Changing boolean to a smallint

From: "Dean Gibson (DB Administrator)" <postgresql(at)ultimeth(dot)com>
To: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Changing boolean to a smallint
Date: 2010-11-04 23:41:01
Message-ID: 4CD3448D.60208@ultimeth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2010-11-04 15:41, Christine Penner wrote:
> I have a table column I want to change from a boolean to a smallint.
> changing false to 0 and true to 1. How do I do that?
>
> Christine Penner
> Ingenious Software
> 250-352-9495
> chris(at)fp2(dot)ca

ALTER TABLE ALTER col_name TYPE SMALLINT
USING CASE WHEN col_name THEN 1 ELSE 0 END;

--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dean Gibson (DB Administrator) 2010-11-04 23:43:39 Re: Changing boolean to a smallint
Previous Message Tatsuo Ishii 2010-11-04 22:41:36 Streaming replication + pgpool-II tutorial