đˇ️ 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
āĻোāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāĻ:
āĻāĻāĻি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āĻ āĻāϰুāύ