Skip site navigation (1) Skip section navigation (2)

Re: ALTER TABLE ( smallinto -> boolean ) ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
Date: 2005-08-29 23:49:39
Message-ID: 15013.1125359379@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> # ALTER TABLE table ALTER COLUMN field1 type boolean;
> ERROR:  column "field1" cannot be cast to type "pg_catalog.bool"

> Should this not work?

No, because there's no built-in cast from smallint to bool.  You could
do something like

... type boolean using case when field1=0 then false else true end;

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2005-08-30 00:18:50
Subject: SHMMAX seems entirely broken in OS X 10.4.2
Previous:From: Rod TaylorDate: 2005-08-29 23:33:31
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...

pgsql-sql by date

Next:From: Matt A.Date: 2005-08-30 03:38:06
Subject: Re: [SQL] question
Previous:From: Rod TaylorDate: 2005-08-29 23:33:31
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group