Search code examples
postgresqlpgadmin-4

Insert image in a database in Postgres


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.


Solution

  • 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;