Is it wise to declare a VARCHAR with a value greater than 255 in MySQL? Is it wise to declare a VARCHAR with a value greater than 255 in MySQL? database database

Is it wise to declare a VARCHAR with a value greater than 255 in MySQL?


As the answer @Eric pointed out suggests, VARCHARs are stored in table while TEXTs are stored in a separate file - the only truly important point that you have to keep in mind when designing a table structure is the row size limitation (MySQL limits each row / record to 65 KB).

I suggest you use VARCHARs for "one-liners" - anything that has a text input as its data source.


The VARCHAR column is limited to 65,535 bytes, which doesn't always mean 65,535 characters depending on which character set you are using.

If your using the latin1 character set which is one byte per character you won't run into any issues because the length of the string in the same as the amount of storage needed.

If you use a character set that stores multi-byte characters you can only set the length to be what the character set will allow. For instance the utf8 character set can have a maximum length of 21,844 characters.


In my opinion, I would discourage to approach. When you need more than 255 characters, use TEXT are some more suitable.

Update: VARCHAR is now limited to 65535 bytes, but a row in MySQL cannot contain more than 65535 bytes.

You have to know that VARCHAR and fields like that are stored directly into your database when TEXT for example will be stored outisde the row why a pointer inside the row linking to it.

So if you want to use big VARCHAR, make sure they will not be too big and won't interfere with the rest of the data in the row.

For example, having mutltiple VARCHAR fields that can contains up to 65K char would be a bad idea.