Question

I understand that PostgreSQL writes BLOB content to a separate table, but is there any way to view the blob contents in an easy and convenient way from inside pgAdmin?

Was it helpful?

Solution 2

I am not sure what you mean by "easy and convenient" but the best you can do is lo_read(...)

This presents the lob as a bytea.

This is easy and convenient in the sense of getting data out but you pgAdmin won't convert from an escaped string back into the original binary for you so you are left looking at the textual representation of the binary, so it is not "easy and convenient" if you want to show the image contained in a lob when that is in png format or anything.

OTHER TIPS

SELECT encode(blobdata::bytea, 'escape') FROM table as o where o.blobdata != ''

where

  1. blobdata is the bytea column (blob)
  2. "table" is the table that contains the column blobdata

If we need SQL operations through SQL Clients (like pgAdmin) on binary columns, it would be better to use base64 encoding as below

To fetch binary data in base64 format

select id, encode(blob_column::bytea, 'base64') as blob_column from blob_table where id=1;

To update binary data by providing base64 formatted data

update blob_table set blob_column = decode('J0u0v1h4CulinCwUvk4dhw==', 'base64') where id=1;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top