In MySQL, when VARCHAR data type will use 1-byte and when 2-bytes prefix length along with data?length along with data?


As we know that in MySQL, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. This length prefix points out the number of bytes in the value of data. The data value itself will decide that when VARCHAR data type will use 1-byte and when 2-byte prefix length.

  • A column uses 1-byte length if values require no more than 255 bytes.
  • A column uses 2-byte length if values may require more than 255 bytes.

Updated on: 28-Jan-2020

71 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements