PDA

View Full Version : Store more chars in a field


bcarl314
12-19-2002, 11:22 AM
Is there a way to store say 2000 charecters in a field? I thought varchar is limited to 255, but I would like to store about 2000-3000. What field type would accomidate that, if any? Or do I need to write text files?

WA
12-19-2002, 12:04 PM
I believe the next smallest unit after varchar is TEXT, which can store 65535 characters.

Kiwi
12-19-2002, 12:08 PM
You can probably use a text data-type. Here's some general notes on the text type (http://www.mysql.com/doc/en/BLOB.html). TEXT can store about 64k characters. It's also worth a look here for information about the type size (http://www.mysql.com/doc/en/String_types.html).

The problem with large types is that they are very inefficient when storing information in the database (ie they take up a lot more room). There are also problems with searching them. As a rule, if you have long text data types, it might be sensible to think about putting them in text-files and linking to the text files.

bcarl314
12-19-2002, 12:18 PM
Wow! Thanks for the quick replies. I'm looking a developing a gallery for people to post and sell photographs, and I would like to offer users the ability to add a description, which can be searched by other users. I think searching text files would take too long. If I limit the size to 2000-3000 chars, how much is that going to slow down searches? Say on 500-1000 entries?

Kiwi
12-19-2002, 12:32 PM
Sorry, I wasn't clear. It's only if you're searching (SELECTing) on that field -- as one of the where clauses. I think in other cases it'll slow things down a little, but not much. Chances are you won't notice it for a sample that small.

I'm not entirely sure how mySql optimises the storage of text strings or if you can set the length on it. If you hunt through the docs, I'm sure you'll find an answer.

<edit>
I still wasn't clear. Hopefully this version will be.
</edit>