🈷️ SQL NCHAR, NVARCHAR2 & INTERVAL

🈷️ SQL Data Types: NCHAR, NVARCHAR2, INTERVAL

In this tutorial, you’ll learn about NCHAR, NVARCHAR2, and INTERVAL — data types used for supporting Unicode characters and handling time durations.

🔤 1️⃣ NCHAR (National Character)

Syntax: NCHAR(n)

Purpose: Stores fixed-length Unicode (international) characters, such as Bangla, Arabic, Chinese.

NCHAR(10) -- Always reserves 10 characters, padding with spaces

Example: Bangla name:

name NCHAR(20)  
-- 'āύাāϏāϰিāύ' will be stored as Unicode

📝 2️⃣ NVARCHAR2 (National Variable Character)

Syntax: NVARCHAR2(n)

Purpose: Stores variable-length Unicode text, supports multiple languages like Bangla, Arabic, Chinese without wasting space.

comment NVARCHAR2(200)

Example: Storing a Bangla message or review:

INSERT INTO feedbacks (comment)
VALUES (N'āϏেāĻŦা āĻ–ুāĻŦāχ āĻ­াāϞো āĻ›িāϞ');

⏳ 3️⃣ INTERVAL

Purpose: Stores time durations or differences — useful for finding the gap between two timestamps or dates.

▶️ INTERVAL YEAR TO MONTH

INTERVAL '2-6' YEAR TO MONTH  
-- means: 2 years and 6 months

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ