Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgAdmin III: How to view a blob?

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?

like image 424
Haroldo_OK Avatar asked Feb 14 '13 13:02

Haroldo_OK


People also ask

How can you view the data via PgAdmin?

To view or modify data, right click on a table or view name in the Browser tree control. When the context menu opens, use the View/Edit Data menu to specify the number of rows you would like to display in the editor panel. To modify the content of a table, each row in the table must be uniquely identifiable.

What are blobs in PgAdmin?

“Blob” stands for “binary large object” and refers to raw binary data stored in a database. Blobs can be images, audios, or other large file formats. Databases handle blobs differently, and here we will see an example of how an image is processed in PostgreSQL and PHP.

How do you define BLOB in PostgreSQL?

PostgreSQL blob data type is defined as binary large object, basically blob data type is not available in PostgreSQL instead of blob we have using bytea data type. Blob data type in PostgreSQL is basically used to store the binary data such as content of file in PostgreSQL.

Does PostgreSQL support BLOB?

PostgreSQL does not support BLOB but you can use the BYTEA data type for storing the binary data.


2 Answers

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
like image 93
Stupidfrog Avatar answered Nov 16 '22 02:11

Stupidfrog


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;
like image 45
Anil Agrawal Avatar answered Nov 16 '22 01:11

Anil Agrawal