B
B
beduin012016-04-07 11:17:54
PostgreSQL
beduin01, 2016-04-07 11:17:54

What is the best way to store blob data in PG?

I read that in PG instead of the blob data type there is bytea, but as I understand it, it also stores data not as a binary string, but encodes it into ASCII.
As a result, I tried to fill in a blob (picture) there. She flooded, but like this . I tried to unload it using a programming language, allocating `byte[]` for it, but I got a string like this at the output.
`[56, 57, 53, 48, 52, 101, 52, 55, 48, 100, 48, 97, 49 ...`
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shelemetiev, 2016-04-07
@zoroda

How PostgreSQL stores bytea on disk is a different story. But for a developer, the bytea type means precisely binary data. pgAdmin displays this data by replacing non-printable characters with their hexadecimal representation.
With the programming language, too, everything is fair. You declared a byte[] array of bytes and received binary data as a byte array.
It's more like a question of how to work with blobs in your programming language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question