开发者

MySQL - TEXT vs CHAR and VARCHAR

Reading this question, a doubt popped into my head:

  • char and varchar can store up to 255 chars
  • text can store up to 65k chars
  • char size in bytes is number of chars
  • varchar size in bytes is number of chars used + 1

So how much bytes does TEXT actually occupy? ~65KB or number of chars used + 开发者_StackOverflow1?


TEXT is a variable length datatype, with a maximum of 65,000 characters.

LONGTEXT can be used for over 4 trillion characters.

To answer your question: it's a variable lenght, and it will only occupy the amount of characters you store.


TEXT occupies a number actual length of your data + 2 bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜