I am aware of the fact that TEXT in MySQL can have maxlength of 65535 characters.
Now I create a table having one of the columns as TEXT and don't specify a length. Due to which it will take maxlength as 65535 default.
However if one of my records has a value for the TEXT column with length only as 10 characters, will the space allocated for 65535 characters be still reserved or will MySQL just use up memory required for 10 characters only?
For TEXT datatype it would be like the Actual length in bytes of string value + (2 Bytes)
The manual says:
Variable-length string types are stored using a length prefix plus data. The length prefix requires from one to four bytes depending on the data type, and the value of the prefix is L (the byte length of the string). For example, storage for a MEDIUMTEXT value requires L bytes to store the value plus three bytes to store the length of the value.
VARCHAR, VARBINARY, and the BLOB and TEXT types are variable-length types. For each, the storage requirements depend on these factors:
- The actual length of the column value
- The column's maximum possible length
- The character set used for the column, because some character sets contain multibyte characters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With