1

I am storing 250 character long text messages into my mysql DB.

What type should I store it as? Right now I am using text which is (64KB) and that seems to be a little to much of what I need. Or must I use the type (text) of I want to support muliple languishes utf-8 ?

user2636197
  • 3,982
  • 9
  • 48
  • 69
  • 3
    check this :http://stackoverflow.com/questions/2023481/mysql-large-varchar-vs-text – TheGameiswar Oct 10 '16 at 13:58
  • I would suggest that you need to decide whether you are going to query against the column based on some of its contents. If the answer to that is yes, you should use text with a fulltext index. If no, I would go for varchar because it is actually stored inline. How often is the field updated? – T Gray Oct 10 '16 at 16:14
  • @TGray I will never peform any search against the text. And the field is never updated – user2636197 Oct 10 '16 at 19:12

3 Answers3

2

I think a varchar(255) is enought for your case. Just test it and see if it's good ;)

0

varchar with a suitable length is better than text in your case.

Tung Nguyen
  • 767
  • 7
  • 6
-1

First, a TEXT type is not 64K but goes up to GBs. Second, if your string is 250 chars, why don't you use VARCHAR which can accommodate up to 64K (which is more than enough even if you have UTF-8 encoding?

FDavidov
  • 3,505
  • 6
  • 23
  • 59
  • This is incorrect. MySQL's `TEXT` field maxes out at about 64K. For more, you need `MEDIUMTEXT` or `LONGTEXT`. http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html – ceejayoz Oct 10 '16 at 14:24