Re: [GENERAL] how to save a bytea value into a file?

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>, "fanlijing *EXTERN*" <fanlijing(at)cn(dot)fujitsu(dot)com>, <pgsql-admin(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] how to save a bytea value into a file?
Date: 2011-10-10 14:26:26
Message-ID: D960CB61B694CF459DCFB4B0128514C206F74397@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

I wrote:
[fanlijing wants to write bytea to file]
> A simple
> COPY (SELECT byteacol WROM mytab WHERE ...) TO 'filename' (FORMAT
binary)
> should do the trick.

Corrections:
a) "binary" must be surrounded by single quotes.
b) that won't dump just the binary data - you would have
to remove the first 25 bytes and the last 2 bytes...

So maybe using the functions I mentioned would be the
best way after all.

You could also write your own user defined function in C.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Merlin Moncure 2011-10-10 15:51:14 Re: [GENERAL] how to save a bytea value into a file?
Previous Message jesper 2011-10-10 14:17:05 pg_lesslog

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2011-10-10 14:48:07 Re: a dumb question regarding RULES
Previous Message Rafal Pietrak 2011-10-10 14:06:34 a dumb question regarding RULES