About Char,varchar and text usually do not care too much, in general, probably now everyone is using varchar. But when the content to be stored is larger, what is the choice between varchar or text? I don't know......
text, char, varchar are the data in the database storage policy issues, in order to, reasonable
Application storage space is the way that database server data types are divided. For applications, put them
And the string corresponds to it.
Then went to look up some information, by the way, the three types of comparison:
(1) Char:char Needless to say, it is fixed-length format, but the length range is 0~255. When you want to store a character that is less than 255 long, MySQL fills the remaining characters with a space. Therefore, when reading data, the char type of data to be processed, the following space is removed.
(2) varchar: about varchar, some say the maximum length is 255, also some say 65535, Looking at a lot of data, I found this: the varchar type has a maximum length limit of 255 in versions under 5.0.3, whereas in versions 5.0.3 and above, the varchar data type is supported to 65535, which means it can hold 65,532 bytes (note that bytes are not characters!!!). Data (starting and ending bits take up 3 bytes), that is, in 5.0.3 The data that needs to be stored in a fixed text or BLOB format can be stored in a higher version with variable-length varchar, which effectively reduces the size of the database file.
(3) Text: Unlike char and varchar, text can not have a default value, its maximum length is 2 of 16 square-1
Summing up, there are several points:
- frequently changing fields with varchar
- Know the fixed length with Char
- Try to use varchar.
- More than 255 characters can be used only with varchar or text
- Where you can use varchar without text.
The difference between Char,varchar and text types in MySQL