Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are NLS Strings in Oracle SQL?

What are NLS Strings in Oracle SQL which is shown as a difference between char and nchar as well as varchar2 and nvarchar2 data types ? Thank you

like image 900
kaushalpranav Avatar asked Feb 09 '23 19:02

kaushalpranav


2 Answers

Every Oracle database instance has 2 available character set configurations:

  1. The default character set (used by char, varchar2, clob etc. types)
  2. The national character set (used by nchar, nvarchar2, nclob, etc. types)

Because the default character set could be configured to be a character set that doesn't support the full range of Unicode characters (such as Windows 1252), that's why Oracle provides this alternate character set configuration as well, that is guaranteed to support Unicode.

So let's say your database uses Windows-1252 for its default character set (not that I'm recommending it), and UTF-8 for the national (or alternate) character set...

Then if you have a table column where you don't need to support all kinds of weird unicode characters, then you can use a type such as varchar2 if you want to. And by doing so, you may be saving some space.

But if you do have a specific need to store and support unicode characters, then for that very specific instance, your column should be defined as nvarchar2, or some other type that uses the national character set.

That said, if your database's default character set is already a character set that supports Unicode, then using the nchar, nvarchar2, etc. types is not really necessary.

You can find more complete information on the topic here.

like image 140
sstan Avatar answered Feb 12 '23 11:02

sstan


AFAIK, NLS stands for National Language Support which supports local languages (In other words supporting Localization). From Oracle Documentation

National Language Support (NLS) is a technology enabling Oracle applications to interact with users in their native language, using their conventions for displaying data

like image 32
Rahul Avatar answered Feb 12 '23 11:02

Rahul