MySQL --- the difference between char and varchar

The difference between char and varchar

  • char length with a constant, i.e. fixed length. VARCHAR variable length represented, i.e. a variable length.
  • When the input data is shorter than the defined length, char will be padded with spaces, and stored in accordance with the actual length varchar.
  • Since the fixed length, char access speed faster than varchar, but will take up extra space. VARCHAR is the contrary, access speed is slower, but the space saving.
  • Char up to the number of characters stored is irrelevant 255, and coding. VARCHAR can store up to 65,532 characters, which is determined by the maximum effective length of the maximum row size and character sets.

Guess you like

Origin www.cnblogs.com/KX-Lau/p/12637922.html