Re: In-place conversion of type bool

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: J(dot)Kraaijeveld(at)Askesis(dot)nl
Cc: "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: In-place conversion of type bool
Date: 2008-08-14 01:27:37
Message-ID: 20916.1218677257@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)nl> writes:
> The database says that it's bool implementation is char(1), just as
> PostgreSQL does. I can copy te data OK, but I would like to change the
> actual type of the column from char(1) to bool. Is that possible without
> copying the column to a temporary column, dropping the old column and
> renaming the temporary columns to the old column?

ALTER TABLE ... ALTER COLUMN TYPE might help you. Use the USING clause
if you need a non-default data conversion -- in this case it might look
like USING (col = '1') or some such.

(This is probably not physically more efficient than making a temp
table, however.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-08-14 01:37:18 Re: automatic REINDEX-ing
Previous Message Tom Lane 2008-08-14 01:21:55 Re: Column alias in where clause?