10

What is the maximum range of varchar in MySQL?

I am using the latest version of MySQL and in many sites it is being told that the size is 255. But when i am trying to give a higher size like 500 or 1000, it works for me. So is there a maximum number for varchar datatype?

Deviprasad Das
  • 4,203
  • 7
  • 36
  • 51

3 Answers3

9

It was 255 before 5.0.3, but now:

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535.

The documentation of 5.0.x shows the transition:

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
6

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

see http://dev.mysql.com/doc/refman/5.1/en/char.html

Wavyx
  • 1,715
  • 2
  • 14
  • 23
2

From the specs

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

verdesmarald
  • 11,646
  • 2
  • 44
  • 60