Re: Text(1024)
Posted by:
Rick James
Date: April 03, 2011 05:21PM
Older versions of MySQL limited VARCHAR to 255.
TINYTEXT and shorter VARCHARs need 1 byte for length. TEXT and longer VARCHARs need 2 bytes.
Using VARCHAR(1024) will truncate text as you INSERT, but won't otherwise save any space. If truncation is desired, then use it.
Note that there are subtle differences in the limits, and on bytes versus characters, when you get into utf8 CHARSET.
Why the "jump"? --
255 = 2**8-1, that is the largest number that can be held in one byte. (A byte is 8 bits.)
65535 = 2**16-1 -- 2 byte limit. (Also limit for SMALLINT UNSIGNED.)
16M -- max for MEDIUMTEXT/MEDIUMBLOB, MEDIUMINT UNSIGNED (3 bytes).
4G -- LONG...
BIGINT occupies 8 bytes; the UNSIGNED version has a max of 2**64-1.
Subject
Written By
Posted
Re: Text(1024)
April 03, 2011 05:21PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.