SqlServer in the difference -char varchar nvarchar

Nvarchar and varchar talk about the difference of: the difference between:     
varchar:  variable length, ANSI character memory, the data is automatically changed according to the length.     
nvarchar: variable length, to store Unicode character data is automatically changed according to the length.     
nvarchar (n): comprises a variable-length Unicode character data of n characters. The value of n must be between 1 and 4,000. Bytes of storage size is twice the number of the character input.      
varchar [(n)]: length n bytes of variable length and non-Unicode character data. n must be a number between 1 and 8,000 nm. Storing input data byte size of the actual length, instead of n bytes

As can be seen from the above nvarchar character is stored as a Unicode,

Here you can take a look at this blog:
the various codes Detailed: http://blog.csdn.net/lvxiangan/article/details/8151670
it can be said that the provisions nvarchar double-byte storage, whether you are storing characters or letters are two bytes,      
analysis nvarchar advantages and disadvantages:       

Advantages: judgment string can be no need to consider differences in both Chinese and English characters garbled problems can be avoided in the program.
Disadvantages: storage English characters doubling of storage space. But at the cost of storage has been very low, the priority compatibility will give you more benefits, efficiency is not high varchar.
char here do not do much to explain the situation consistent with MySQL.  
   
General usage instructions:
data length is determined such as telephone numbers stored, fixed coding, but does not include the Chinese, char type can be selected.   

Indefinite length data stored in the storage only in English, preferably with a digital varchar.

Indefinite length stored data, there may be a Chinese, can select the nvarchar type.

Guess you like

Origin www.cnblogs.com/crrc/p/11248965.html