View Full Version : mySQL' 255 char limit?
SFA-Dark 08-11-2004, 01:44 AM Hey,
You guys know the 255 chars limit in mySQL? Well, when I make a script that has a Description box, are there anyway I can make it so I will see the user's FULL description even if its over 255 chars?
This doesn't have to be mySQL based, it can be PHP stored files or things like that.
Can anyone tell me how I can do this? Or even better if you can write me a basic scripts that I can follow out of :)
Thank you very much
Rich2k 08-11-2004, 02:17 AM Almost all the big databases have a top limit of 255 on a VARCHAR, even Oracle.
You could use LONGTEXT but it's not a standard.
What you need to do is some form of splitting at 255 characters and put each chunk of 255 characters as a new entry in the database. Then at run time piece them all back together again.
laserlight 08-11-2004, 02:17 AM Use a different column type, e.g. a TEXT or BLOB field.
SFA-Dark 08-11-2004, 02:28 AM can you guys give me like an example of how this should be done? Im not that experienced with mysql and php.
thx
JimPanse 08-11-2004, 03:22 AM open your phpmyadmin select table and field properties and switch to filedtype mediumtext instead of varchar.
Theres nithing to explain. This field just can store about 16mb data.
The one thing is. Try never out to add an index to a mediumtext (blob text) filed or do any searches in where-conditions on this kind of fileds.
It takes huges
azizny 08-11-2004, 11:13 AM QUERY:
ALTER TABLE `userlist` CHANGE `username` `username` TEXT NOT NULL
Where userlist is the table name - username is the field name, TEXT is the new type to assocaited with
Peace,
cblc3kw 08-14-2004, 01:28 PM You can also use the tools like MySQL Administrator and DBDesigner for designing your MySQL databases.
FliesLikeABrick 08-15-2004, 11:42 AM use the TEXT field type.
What does varchar provide over text though, for strings under 255 chars?
-Brick
laserlight 08-15-2004, 12:34 PM What does varchar provide over text though, for strings under 255 chars?
Quite a few, e.g. VARCHAR fields can be indexed.
FliesLikeABrick 08-15-2004, 12:57 PM oh, figures i didn't know that sinve i'm not yet familiar with indexes
-Brick
Rich2k 08-15-2004, 12:59 PM If you want to perform a text search on a database, you really need indexes, otherwise your search will be VERY slow. (very noticable on large multi gigabyte databases especially... if you have no indexes you basically can't do a search in those situations).
FliesLikeABrick 08-15-2004, 01:24 PM i'm not sure how to use indexes yet, but multi gigabyte is one big database anyway... my entire stats database for my game server is just over 1MB with 10,000 rows and 75 fields. about 97% of the fields are integers, and the only varchar field is the player name.
-Brick
thartdyke 08-15-2004, 04:13 PM You can index a TEXT field. You specify the prefix length, i.e., how much of the start of the field is used for the index.
If you use text fields, use full text search on that field, they can be very fast as well.
Chet
|