Mysql Text Storage?

I was wondering if you have an article or articles with a huge amount of text, what would be better when creating a database structure for the text of the articles? And why?

What will be the advantages or disadvantages, if any?

I thought of using one of the data types below to store the text of articles for a MySQL database.

VARCHAR
TEXT
MEDIUMTEXT
LONGTEXT
0
source share
3 answers

Please see the MySQL documentation for an explanation of the differences between these types.

But to answer your question, VARCHAR is a user-length field, and text fields have a system size:

  • VarChar [1-whatever (max at 65535)]
  • TinyText 255 (2 ^ 8 - 1)
  • Text 65535 (2 ^ 16 - 1)
  • MediumText 16M (2 ^ 24 - 1)
  • LongText 4G (2 ^ 32 - 1)

, VarChar , , 255.

+5
+1

VARCHAR TEXT , . VARCHAR , MySQL 65,535 . TEXT , , , .

My suggestion was to always use VARCHAR for small amounts of text and reserve a TEXT when you need to store significant amounts.

If you use TEXT fields, be sure to exclude them from SELECT queries if you do not need them, as this will speed up query execution.

0
source

Source: https://habr.com/ru/post/1523808/


All Articles