Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text or varchar?

Tags:

types

sql

mysql

I have 2 columns containing text one will be max 150 chars long and the other max 700 chars long,
My question is, should I use for both varchar types or should I use text for the 700 chars long column ? why ?

Thanks,

like image 360
Mike Avatar asked Dec 18 '22 05:12

Mike


1 Answers

The varchar data type in MySQL < 5.0.3 cannot hold data longer than 255 characters. While in MySQL >= 5.0.3 it has a maximum of 65,535 characters.

So, it depends on the platform you're targeting, and your deployability requirements. If you want to be sure that it will work on MySQL versions less than 5.0.3, go with a text type data field for your longer column

  • http://dev.mysql.com/doc/refman/5.0/en/char.html
like image 186
jason Avatar answered Jan 02 '23 22:01

jason