Current location - Loan Platform Complete Network - Big data management - Database: char and varchar data types what are the differences?
Database: char and varchar data types what are the differences?
1.var prefix, that is, the actual storage space is a variable length, varchar, nvarchar the so-called fixed-length is a fixed length, when the length of the input data does not reach the length of the specified length will automatically fill the English space behind it, so that the length of the length to reach the corresponding length; and variable-length character data will not be filled with spaces, the exception is that the text store also Unicode characters, that is, all characters account for two bytes, nchar, nvarchar characters, English characters only need a byte to store enough, but many Chinese characters, need two bytes to store, English and Chinese characters at the same time is easy to cause confusion, the Unicode character set is designed to solve the incompatibility of the character set and the emergence of the problem, it is all characters are stored in a single byte, the character set is used in the character set. It all characters are expressed in two bytes, that is, English characters are also expressed in two bytes. 3. Based on the above two points to see the field capacity char, varchar up to 8000 English, 4000 Chinese characters nchar, nvarchar can store 4000 characters, whether English or Chinese 4. use (personal preference) a. If the amount of data is very large, and can 100% determine the length and save the and can 100% determine the length and save just ansi characters, then charb. can determine the length and not necessarily ansi characters or, then use nchar; c. For very large data, such as the content of the article, the use of nTextd. other general purpose nvarchar