Re: bytea type

From: Joe Conway <mail(at)joeconway(dot)com>
To: Felipe Schnack <felipes(at)ritterdosreis(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: bytea type
Date: 2002-10-10 14:28:00
Message-ID: 3DA58E70.5000603@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Felipe Schnack wrote:
> How I convert a bytea column to a varchar?

-- this is just to show that the \\000 is actually a single character in bytea
test=# select length('abc\\000def'::bytea);
length
--------
7
(1 row)

-- here's how to convert to varchar
test=# select encode('abc\\000def'::bytea,'escape')::varchar;
encode
------------
abc\000def
(1 row)

Note that certain characters get escaped because they are not representable in
text or varchar. See:
http://www.postgresql.org/idocs/index.php?functions-string.html
for (a bit) more on the encode function.

Joe

In response to

  • bytea type at 2002-10-10 12:24:58 from Felipe Schnack

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2002-10-10 14:29:10 Re: access time performance problem
Previous Message Joe Conway 2002-10-10 14:18:16 Re: user name lost from dictionary