Re: Casting bytea to varchar

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "Rajagopalan, Jayashree *EXTERN*" <Jayashree(dot)Rajagopalan(at)emc(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Casting bytea to varchar
Date: 2013-01-15 15:40:00
Message-ID: 25980.1358264400@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> You cannot specify a conversion function while altering
> a column's type, you'd have to use a new column like this:

Sure you can; that's the whole point of the USING option.
It'd look something like

ALTER TABLE test ALTER COLUMN val TYPE varchar(255) USING convert(val);

with whatever is appropriate in place of convert().

But the real question of course is what is "appropriate" for the OP's
situation --- he didn't specify exactly what he's got in his bytea
column or how that should be converted to varchar.

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Albe Laurenz 2013-01-15 15:56:30 Re: Casting bytea to varchar
Previous Message Heikki Linnakangas 2013-01-15 10:57:23 Re: corrupted indexes when using base backups generated from hot standby