MySQL VARCHAR maximum size

Programming for Search Engines 101. An area for avid PHP and .NET developers to chat about Programming techniques and how to make better use of search engines.

Moderator: Moderators

MySQL VARCHAR maximum size

Postby ashik » Wed Feb 11, 2009 2:02 am

Hi all,
Not quiet sure if anyone knew about this. Came across this information today and thought would share with everyone.

We are all quiet well versed in giving varchar(255) while defining the data type of columns in MySQL.

Well for those who don't like the number 255 :lol:, you people can start giving any value till the maximum range supported from MySQL version 5.0.03 or higher and that would be till 65535; well technically till 65533 so to speak .. confused ???? :twisted: well we were initially till we figured out the semantics behind it.

do find the explanation below:

The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

if the varchar size is < 255 then a byte per row will be used to store the metadata.

A varchar field with a size > 255 will use 2 bytes for the meta data storage. and this explains what i had mentioned earlier in this post i.e. of the maximum range that could be assigned to the varchar field 65533

Regards,

Ashik Pasha
ashik
 

Return to Programming

Who is online

Users browsing this forum: No registered users and 7 guests