What is the difference between varchar and nvarchar in the database? varcharnvarchar

Source: Internet
Author: User

What is the difference between varchar and nvarchar in the database? varcharnvarchar

Differences between varchar and nvarchar in Databases

1. varchar is stored in bytes, while nvarchar is stored in characters (two bytes. That is to say, varchar stores one English letter in one byte and one Chinese Character in two bytes, while nvarchar stores one English letter in two bytes and one Chinese Character in two bytes.

2. varchar (n) indicates that the length is n Bytes, and nvarchar (n) indicates that the length is n characters (2n bytes ).

3. nvarchar is used to store double-byte characters such as Chinese characters. Therefore, if you confirm that the field value does not contain English characters, try to use nvarchar for storage.

4. Another benefit of using nvarchar is that Chinese characters do not change to "?" during database operations "?? .

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.