Difference between VARCHAR2(10 CHAR) and NVARCHAR2(10)

difference between varchar2 and nvarchar2
varchar2 byte vs char
difference between varchar and varchar2
difference between varchar and varchar2 and nvarchar
convert varchar2 byte to char oracle
nvarchar2 max size in oracle 12c
oracle column size in bytes

I've installed Oracle Database 10g Express Edition (Universal) with the default settings:


NLS_CHARACTERSET               AL32UTF8                                 
NLS_NCHAR_CHARACTERSET         AL16UTF16                                

Given that both CHAR and NCHAR data types seem to accept multi-byte strings, what is the exact difference between these two column definitions?


Ask TOM "difference between varchar2(10) and varchar2(10 ch", difference between varchar2(10) and varchar2(10 char) in oracle Varchar2(10) uses the current value of NLS_LENGTH_SEMANTICS to determine the limit for the NVARCHAR2 NVARCHAR2 NVARCHAR2 NVARCHAR2  In multibyte character sets these can be different! So if NLS_LENGTH_SEMANTICS = byte, you may only be able to store 5 characters in your varchar2. So varchar2(10 char) is explicit. This can store up to 10 characters. Varchar2(10) is implicit. It may store 10 bytes or 10 characters, depending on the DB configuration. It's better to be explicit (10 char).

I don't think answer from Vincent Malgrat is correct. When NVARCHAR2 was introduced long time ago nobody was even talking about Unicode.

Initially Oracle provided VARCHAR2 and NVARCHAR2 to support localization. Common data (include PL/SQL) was hold in VARCHAR2, most likely US7ASCII these days. Then you could apply NLS_NCHAR_CHARACTERSET individually (e.g. WE8ISO8859P1) for each of your customer in any country without touching the common part of your application.

Nowadays character set AL32UTF8 is the default which fully supports Unicode. In my opinion today there is no reason anymore to use NLS_NCHAR_CHARACTERSET, i.e. NVARCHAR2, NCHAR2, NCLOB. Note, there are more and more Oracle native functions which do not support NVARCHAR2, so you should really avoid it. Maybe the only reason is when you have to support mainly Asian characters where AL16UTF16 consumes less storage compared to AL32UTF8.

Difference between nvarchar2( 10) and varchar2( 10 char), Difference between nvarchar2( 10) and varchar2( 10 char) - SQL & PL/SQL. NVARCHAR2(10) you tell Oracle it can store 10 characters with 2 bytes per character; In Summary: VARCHAR2(10 CHAR) can store maximum of 10 characters and maximum of 40 bytes (depends on the configured national character set). NVARCHAR2(10) can store maximum of 10 characters and maximum of 20 bytes (depends on the configured national character set).

Oracle NVARCHAR2 Data Type, NVARCHAR2 vs. VARCHAR2, data type and explains the differences between NVARCHAR2 and VARCHAR2. The NVARCHAR2 is Unicode data type that can store Unicode characters. in the result, the datatype code 1 is and the length is 10 bytes (5 characters,  varchar2 (10 char) is unambiguous - it is 10 characters varchar2 (10) is ambiguous - it is either 10 characters or 10 bytes, depending upon what NLS_LENGTH_SEMANTICS was set to at the time the column was created. The default, as you imply, is byte, but if it's was char, then varchar2 (10) and varchar2 (10 char) are exactly the same.

nVarchar2 is a Unicode-only storage.

Though both data types are variable length String datatypes, you can notice the difference in how they store values. Each character is stored in bytes. As we know, not all languages have alphabets with same length, eg, English alphabet needs 1 byte per character, however, languages like Japanese or Chinese need more than 1 byte for storing a character.

When you specify varchar2(10), you are telling the DB that only 10 bytes of data will be stored. But, when you say nVarchar2(10), it means 10 characters will be stored. In this case, you don't have to worry about the number of bytes each character takes.

An Essential Guide to Oracle VARCHAR2 by Examples, In addition, if you store 10 characters in a VARCHAR2(20) column, Oracle uses only 10 bytes for storage, not 20 bytes. When comparing VARCHAR2 values, Oracle uses the non-padded comparison semantics. Next Oracle NVARCHAR2  VARCHAR2 vs. NVARCHAR2. First, the maximum size of VARCHAR2 can be in either bytes or characters, whereas the maximum size of NVARCHAR2 is only in characters. In addition, the maximum byte length of an NVARCHAR2 depends on the configured national character set.

Difference Between Char, Nchar, Varchar and Nvarchar Data Types , CHAR vs VARCHAR, NCHAR vs NVARCHAR, difference between 5 characters, therefore it will occupy 10 bytes of space in the database. Differences: CHAR vs VARCHAR vs VARCHAR2. Let’s take a look at the differences between these three data types. VARCHAR and VARCHAR2 are exactly the same. CHAR is different. CHAR has a maximum size of 2000 bytes, and VARCHAR/VARCHAR2 has a maximum size of 4000 bytes (or 32,767 in Oracle 12c) CHAR does not need a size specified and has a

Oracle Database, This will support to up 10 characters of data, which could be as much as 40 bytes of information. the CHAR modifier in the VARCHAR2/CHAR definition. Do you wonder the difference between nvarchar vs varchar? This article discusses the differences between CHAR, VARCHAR, NCHAR and NVARCHAR data types. CHAR vs VARCHAR, NCHAR vs NVARCHAR, difference between char and varchar, difference between nchar and nvarchar.

Difference between varchar and varchar2, But it allocates space for entire 15 characters. 3) Allocate variable size of data based on input. Ex: We defined varchar2 (15) and entered only 10 characters. Then  quand vous spécifiez varchar2(10) , vous dites au DB que seulement 10 octets de données seront stockées. Mais, quand vous dites nVarchar2 (10) , cela signifie 10 caractères sera stocké. Dans ce cas, vous n'avez pas à vous soucier du nombre d'octets de chaque personnage.

  • I easily assumed Unicode nature in N... types because I also work with SQL Server, which apparently (I'm not a guru in either DBMS) links VARCHAR/NVARCHAR to ANSI/Unicode Windows codepages, but of course Oracle is much older. In practice, perhaps N... can be left as potentially less obtrusive option for redistributable applications. Companies run really old legacy software in shared instances and it's less likely to get Unicode in VARCHAR2 than it is in NVARCHAR2.
  • "The AL16UTF16 use 2 bytes to store a character". UTF-16 is variable-length and some characters require 4 bytes—does it mean that VARCHAR2 is fully Unicode compatible and NVARCHAR2 isn't? Or it's just an over-simplification?
  • Hi @ÁlvaroGonzález: We can say that VARCHAR2 is compatible with Unicode but support single character set while NVARCHAR2 support Unicode with multiple character set. One reason you may want to use NVARCHAR2 might be that your DB uses a non-Unicode character set and you still want to be able to store Unicode data for some columns without changing the primary character set.
  • Another reason might be that you want to use two Unicode character set (AL32UTF8 for data that comes mostly from western Europe, AL16UTF16 for data that comes mostly from Asia for example) because different character sets won't store the same data equally efficiently.
  • But I don't have VARCHAR2(10), I have VARCHAR2(10 CHAR), i.e., I'm not relying on the system's default semantics, I'm explicitly stating I want characters not bytes.
  • Yes, you are right! In that case, both would be able to store same length of characters.
  • Not fully correct. When you specify varchar2(10) then it could mean varchar2(10 BYTE) or varchar2(10 CHAR). The default is defined by session parameter NLS_LENGTH_SEMANTICS. However, NCHAR, NVARCHAR2, CLOB, and NCLOB are always CHAR.