Data types in MySQL (String type)Character Typedata types in the six databaseschar, varchar, text, Blob,enum,setChar and varcharchar fixed length: Disk space is wasted, but high efficiency, determine the length of the data is the same, the use of fixed lengthFor example: phone number, ID numbervarchar Edge Length: Relatively space saving, but inefficient, the data can not be determined length (different data length varies)For example: AddressText type:if the amount of data is very large, usually 255 characters more, use text typethe Text type has a maximum record length of 10 bytes (primarily used to store addresses and lengths)Text categorytext and BLOBsText : Storing text (necessary protocols, notes, etc.)blob: Storing binary data (usually not), binary data is actually a storage pathEnum Typedesign the possible results beforehand, and the actual stored data must be one of the enumerationenumeration The data that is actually stored in the database is numeric rather than a stringHow to use: Enum (List of elements that may appear)use: Store data and store only the data defined above Enumeration principle:enumeration in the data specification, the system will automatically establish a number and enumeration elements corresponding to the relationship (stored in the log), and then the data inserted, the system automatically converts the string to the corresponding digital storage, and then when the data extraction, The system automatically converts the value to the corresponding character length for display Collection String Setcollections and enumerations are similar: actual stored values instead of strings (the collection is multi-selected)How collections are useddefinition: Set (element list)use: You can use one or more of the list of elements, separated by commasInsert Data: You can use multiple element string combinations, or you can insert values directlyeach element in the collection corresponds to a BITS, 1 is selected, 0 is unchecked, and right -to-left is takenThe ordering relationship of the elements in the collection: Actually, it is the bitwise operation (negation) length of maximum record in MySQLtheoretically the maximum length is 65535 bytes (in fact never reached)maximum length under UTF8 character set: 21844 21844 * 3 + 2 = 65534Maximum length under GBK character set: 32766 32766 * 2 + 2 = 65534 MySQL recordif any one of the fields is allowed to be empty, the system automatically retains one byte from the entire record to store null (the byte that the weak wants to release null: You must ensure that all fields are not allowed to be empty)
(4) Data types in MySQL (String type)