What is difference between Varchar2 and Nvarchar2?

Showing Answers 1 - 3 of 3 Answers

Sibi John

  • Sep 11th, 2006
 

Varchar2(s) is used to define a variable length character of maximum size s.

Nvarchar2: Same as VARCHAR2 except that the column stores values in the  National CS , ie you can store values in Bangla if your National CS is BN8BSCII .If the National CS is of fixed width CS (all characters are represented by a fixed byte ,say 2 bytes for JA16EUCFIXED) , then NVARCHAR2(30) stores 30 Characters.

If the National CS is of variable width CS (some characters are represented by 1 byte ,some by 2 bytes as in UTF8 ) , then NVARCHAR2(30) stores 30 bytes.
The maximum column size allowed is 4000 bytes.
 Ex: CREATE TABLE tab1 (col1 NVARCHAR2(2000)); will create a table with one NVARCHAR2 column of 2000 characters in length (stored as 4000 bytes, because each character takes two bytes) using JA16EUCFIXED as the national character set:
 

  Was this answer useful?  Yes

Jai Prakash Vishwakarma

  • Sep 12th, 2006
 

SQL Server provides both datatypes to store character information. For the most part the two datatypes are identical in how you would work with them within SQL Server or from an application. The difference is that nvarchar is used to store unicode data, which is used to store multilingual data in your database tables. Other languages have an extended set of character codes that need to be saved and this datatype allows for this extension. If your database will not be storing multilingual data you should use the varchar datatype instead. The reason for this is that nvarchar takes twice as much space as varchar, this is because of the need to store the extended character codes for other languages.

  Was this answer useful?  Yes


In simple

Varchar2 works with 8 bit characters where as Nvarchar2 works ith 16 bit characters.

If you have to store data other than english prefer Nvarchar2 or viceversa.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions