Nchar Datatype in Oracle Database

In this Oracle tutorial, we will learn about the Nchar datatype in the oracle database. Also, we will demonstrate how to use it to create Nchar columns for a table in oracle.

Introduction to Oracle Nchar datatype

A word string that can store Unicode information is known as an n-char and the nchar stands for national character.

NCHAR can only use the national character sets AL16UTF16 or UTF8, which are defined when the database is created.

Oracle Nchar datatype Syntax

So far, we’ve clarified the meaning of the Nchar datatype and discussed how it’s used in databases. The next step will be to learn how to utilize it to add Nchar columns to an Oracle table.

The syntax for using a Nchar datatype in Oracle 21c, which is provided below, must be understood in order to perform this in an example.

column_name datatype(size)

where column_name is the name of the column, the datatype is nchar, and size is the number of characters that the column can store. The size of a nchar column must be specified in characters, and the maximum size is 2000 characters.

Also, check: How to add a column to a table in Oracle

Oracle Nchar datatype Examples

Note that the nchar datatype uses twice the amount of storage as the char datatype because it stores each character as two bytes in the database.

Now we will create a table by statement and check how we can use the Nchar datatype in the given department table.

CREATE TABLE department (
  dept_id number,
  department_name nchar(100),
  job_title nchar(50)

Now we will insert the data into a table

INSERT INTO department (dept_id, department_name, job_title)
VALUES (872, 'Micheal', 'Manager');

INSERT INTO department (dept_id, department_name, job_title)
VALUES (672, 'John', 'Developer');
nchar datatype use in oracle
nchar datatype used in oracle

Read: How to add a primary key in Oracle

Now, we will discuss how to use the Nchar datatype in the SQL developer tool manually.

nchar datatype use in sql developer tool
nchar datatype use in an SQL developer tool

Here, we inserted the column name ‘Country_name’ and provide the Nchar datatype with the size (100).

Now we will insert the values into a table.

INSERT INTO country (country_name) VALUES ('U.S.A');
created table in oracle with nchar datatype
created table in oracle with nchar datatype

You can use the final statement to determine the current national character set

current nchar set
current nchar set in oracle

Also, check: Char Datatype in Oracle Database

The description column has a maximum byte length of 20 bytes since each character in the AL16UTF16 character set requires two bytes to store.


So, in this Oracle tutorial, we understood how to define and use the Nchar Datatype in Oracle Database. And we have also covered a few sample examples related to it.

Also, take a look at some more Oracle tutorials.