The difference between varchar and char

  The difference between VARCHAR and CHAR type data type is subtle, but very important. They are used to store character values ​​less than 255 characters, the maximum support before mysql5.0 is varchar 255.
If the input field data type VARCHAR you to a length of forty characters of Bill Gates . When you later removed from the data in this field, you remove data having a length of ten characters - Bill Gates of the length of the string.
  If you enter a string length of forty characters of type CHAR field, then when you extracted data, the extracted data will be forty characters in length. The end of the string is appended extra space.
When creating the site, you will find the use of VARCHAR type field than CHAR type field more convenient. When using VARCHAR type field, the data does not need to cut off extra spaces worry about.
  Another outstanding benefit of VARCHAR type field is that it can take up less memory and disk space than CHAR type field. When the database is large, memory and disk space savings that will become very important.
  Although VARCHAR use more flexible, but from the perspective of performance for the entire system, CHAR data types of faster processing, and sometimes can exceed 50% VARCHAR processing speed. Therefore, in the design of the database user should consider all factors, in order to achieve the best balance.

 

 

Guess you like

Origin www.cnblogs.com/silver-aircraft/p/11681697.html