Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing images, creating a image blob column? 1

Status
Not open for further replies.

VitoCorleone

Programmer
Jun 22, 2004
28
0
0
GB
Hi,

I would like to add a column so that images can be inserted and viewed from a mysql database. I have set up the table as follows:

CREATE TABLE Staff
(staff_no CHARACTER(5) PRIMARY KEY,
fname CHARACTER VARYING(20),
lname CHARACTER VARYING(20),
position_ CHARACTER VARYING(20),
sex CHARACTER,
dob DATE,
salary DECIMAL(9,2),
supervisor_staff_no CHARACTER(5), -- FOREIGN KEY
branch_no CHARACTER(4)); -- FOREIGN KEY

I have been having problems in finding the right syntax to create the BLOB if that is what i need. Can anyone help?
 
You can use one of the BLOB field types:
TINYBLOB holds up to 255 bytes
BLOB holds up to 64kB
MEDIUMBLOB holds up to 16MB
LONGBLOB holds up to 4GB

For example:[tt]
mugshot BLOB,[/tt]
 
Quick question, how do you store images in a DB? can you add them from php?
 
Is it really worth storing blobs in the DB?

I usually store them on the server and store the link to the binary file in a varchar field.

This way I found development quicker and page performance much faster.
Comments on this are appreciated.

Cheers

QatQat

Life is what happens when you are making other plans.
 
The endless debate, images in db or not...the only answer I have found is:

it depends

It depends on what the business/client requirements are, what the desired speed of the app is, the skill of the coder, and so on....

I wrote examples of insert/retrieving images. Maybe they can help you.

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top