View Full Version : varchar
timgolding
07-23-2007, 01:25 PM
Hi i am creating an SQL table and one of the fields is going to be a image link path. This will be a varchar. But I am unsure what size I should make that. Any ideas. I want to allow for images with long names.:confused:
Daemonspyre
07-23-2007, 01:49 PM
Are you keeping the whole relative path or just the filename?
Most OS's today, even with LongFileName support, will only go to 255 characters.
If you are doing just the filename, I would make it a VARCHAR(255).
If you are keeping the entire relative path + file name, make it a MEDIUMTEXT or LONGTEXT field.
If you are using MySQL 5.0.3 or greater, you can make your VARCHAR field up to 65535 characters.
Here's the text from the manual:
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions. (The maximum effective length of a VARCHAR in MySQL 5.0.3 and later is determined by the maximum row size and the character set used. The maximum column length is subject to a row size of 65,532 bytes.)
http://dev.mysql.com/doc/refman/5.0/en/char.html
timgolding
07-23-2007, 02:25 PM
ok i am doing just the filename now that way i can keep it to 255 thanks for this information.
StupidRalph
07-24-2007, 04:30 AM
I didn't realize they upped varchar's capacity in MySQL >= 5.0.3 I need to take the time and check out the change log.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.