MySQL: Large VARCHAR vs. TEXT?

后端 未结 8 1385
庸人自扰
庸人自扰 2020-11-22 09:21

I\'ve got a messages table in MySQL which records messages between users. Apart from the typical ids and message types (all integer types) I need to save the actual message

8条回答
  •  一个人的身影
    2020-11-22 10:08

    Can you predict how long the user input would be?

    VARCHAR(X)

    Max Length: variable, up to 65,535 bytes (64KB)
    Case: user name, email, country, subject, password


    TEXT

    Max Length: 65,535 bytes (64KB)
    Case: messages, emails, comments, formatted text, html, code, images, links


    MEDIUMTEXT

    Max Length: 16,777,215 bytes (16MB)
    Case: large json bodies, short to medium length books, csv strings


    LONGTEXT

    Max Length: 4,294,967,29 bytes (4GB)
    Case: textbooks, programs, years of logs files, harry potter and the goblet of fire, scientific research logging

    There's more information on this question.

提交回复
热议问题