12 March 2012

Difference between CHAR and NCHAR in Oracle

I'd like to share you with some piece of info I found while searching about the difference between CHAR and NCHAR in Oracle and why Oracle DB has two Charsets

This info I got from SO here. and Here's it:

The NVARCHAR2 datatype was introduced by Oracle for databases that want to use Unicode for some columns while keeping another character set for the rest of the database (which uses VARCHAR2). The NVARCHAR2 is a Unicode-only datatype.
One reason you want to use NVARHCAR2 might be that your DB uses a non-Unicode character and you still want to be able to store Unicode data for some columns. 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.
Both columns in your example (Unicode VARCHAR2(10 CHAR) and NVARCHAR2(10)) would be able to store the same data, however the byte storage will be different. Some strings may be stored more efficiently in one or the other.
Note also that some features won't work with NVARCHAR2, see this SO question:
Oracle Text will not work with NVARCHAR2. What else might be unavailable?



Post a Comment