Turn from http://www.uphtm.com/database/232.html in the MySQL tutorial the difference between char and varchar, are used to store strings, but they are not the same way to save, Char has a fixed length, VARCHAR is a variable-length character type. The difference between char and varchar char (16) fixed length, such as ' www.uphtm.com ' storage takes space 14 characters varchar (16) variable length as ' www.uphtm.com ' requires storage space 15 characters, can be seen from above Char long The degree is fixed, no matter how much data you store, he will be fixed in length. The varchar is variable in length but he adds 1 characters to the total length, which is used to store the location. So the user can do it according to their own data type in actual application. Then look at the difference between char and varchar in speed. Mysal>create Tabe AB (v varchar (4), C char (4)), query OK, 0 rows affected (0.02 sec) Mysql>insert into ABC values (' Ab ', ' AB ') query OK, 1 row affected (0.00 sec), Mysql->select concat (V, ' + '), concat (c, ' + ') Form Abcab + | Ab+1rows in Set (0.00 sec) can be seen from the above, for some reason char fixed length, so the processing speed is much faster than varchar, but to the cost of storage space, so the storage is small, but the speed of the requirements can use the char type, Conversely, you can use the varchar type to instantiate. Note: When you use char character type, there is space behind the content must be related processing, or the space will be automatically deleted. Built in: The MyISAM storage engine recommends using fixed-length, data columns instead of variable-length data columns. The memory storage engine is currently using fixed data row storage, so regardless of whether the Char varchar column is used, the InnoDB storage engine is intended to use the varchar type.
Learn variable-length character types by the difference between char and varchar