Storing small image files

From: Nelson Green <nelsongreen84(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Storing small image files
Date: 2013-05-09 15:04:18
Message-ID: CAGo-KZm7WWVvikV7f2Pyh8dj53DmwEo3=-WSFDpg16Gby5kjhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Good morning list,

I am designing a system that will have a table for security badges, and we
want to store the ID badge photo. These are small files, averaging about
500K in size. We have made the decision to store the image as a BLOB in the
table itself for a variety of reasons. However, I am having trouble
understanding just how to do that.

The table structures:

CREATE TABLE employee
(
employee_id INTEGER NOT NULL,
employee_lastname VARCHAR(35) NOT NULL,
employee_firstname VARCHAR(35) NOT NULL,
employee_mi CHAR(1),
PRIMARY KEY (employee_id)
);

CREATE TABLE security_badge
(
badge_number CHAR(10) NOT NULL,
employee_id INTEGER NOT NULL
REFERENCES employee(employee_id),
badge_photo ????,
PRIMARY KEY (badge_number)
);

What datatype should I use for the badge_photo (bytea?), and what are the
commands to insert the picture accessing the server remotely through psql,
and to retrieve the photos as well, please?

Thanks,
Nelson

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-05-09 15:15:35 Re: Does it make sense to break a large query into separate functions?
Previous Message Bruce Momjian 2013-05-09 14:45:57 Re: [GENERAL] pg_upgrade fails, "mismatch of relation OID" - 9.1.9 to 9.2.4