2

I am totally new to Postgres and I have created a database using pgAdmin4. I would like to ask if it is possible to add a column to my table that contains images.

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

Short answer: You can create table with column type as bytea.

Using:

insert into images(image_name, image_raw) values('image.png', bytea('D:\image.jpg'));

Long answer: Storing Images in DB - Yea or Nay?

Yan
  • 318
  • 2
  • 10
-2

Tip: don't save images in the database, save them on the filesystem and save the path of the image in the database in a text column.

However, if you must save an image you should use bytea column (similar to BLOB in other databases). Use the following command to add a bytea column to an existing table:

alter table_name add column column_name bytea;
halfer
  • 19,824
  • 17
  • 99
  • 186
JeyJ
  • 3,582
  • 4
  • 35
  • 83