Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

database

mysql

I just noticed in the documentation that in versions greater than 5.0.3 of MySQL you can declare varchar's with larger values than 255. In the past I've switched datatypes for anything larger than 255 but I'm wondering if it's better practice now to define larger string values using varchar(1000) or whatever length is appropriate.

Is this common with other databases now as well, or is it best to stick with 255 as the max value and change datatypes above that?

like image 986
ahanson Avatar asked Jan 14 '11 15:01

ahanson


1 Answers

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.

like image 181
Alix Axel Avatar answered Oct 18 '22 19:10

Alix Axel