Re: how to save a bytea value into a file? - Mailing list pgsql-general

From Albe Laurenz
Subject Re: how to save a bytea value into a file?
Date
Msg-id D960CB61B694CF459DCFB4B0128514C206F740C4@exadv11.host.magwien.gv.at
Whole thread Raw
In response to how to save a bytea value into a file?  ("fanlijing" <fanlijing@cn.fujitsu.com>)
Responses Re: how to save a bytea value into a file?  ("fanlijing" <fanlijing@cn.fujitsu.com>)
List pgsql-general
fanlijing wrote:
> When I want to save a bytea value into a file, what should I do?
> Is there any function dealing with that in PostgreSQL? (like lo_export() to
> deal with the large-object) (# I didn't find any....)

If you want to save it in a file on the server, you can use
the COPY statement.

If you want to create that file on the client machine, you'll
have to select and fetch it like any other value, then open
a file and write the contents into it.

If the bytea is large, you could select parts of it (with the
substring() function) and thus do it in pieces.

For some APIs, you could also use COPY TO STDOUT.

Details depend on the API and programming language you are using.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Harshitha S
Date:
Subject: could not create file "base/16384/11500": File exists
Next
From: AI Rumman
Date:
Subject: Permission for pg_shadow.