MySQL Forums
Forum List  »  General

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.

Options: ReplyQuote


Subject
Written By
Posted
April 03, 2011 02:54AM
April 03, 2011 08:06AM
April 03, 2011 08:10AM
April 03, 2011 08:21AM
April 03, 2011 08:25AM
Re: Text(1024)
April 03, 2011 05:21PM
April 03, 2011 05:30PM
April 03, 2011 07:45PM
April 03, 2011 08:00PM
April 03, 2011 09:04PM
April 03, 2011 09:17PM
April 03, 2011 10:29PM
April 04, 2011 02:23AM
April 04, 2011 02:28AM
April 04, 2011 02:42AM


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.