🧩 SQL Data Types
Last Updated: January 2026
SQL Data Types define what kind of data a column can store. They help the database:
- store data efficiently
- validate input values
- improve performance
Hinglish Tip 🗣: Data type column ka rule hota hai — kaunsa data allowed hai aur kaunsa nahi.
🗂️ Main Categories of SQL Data Types
| Category | Purpose |
|---|---|
| Numeric | Store numbers |
| Character / String | Store text values |
| Date & Time | Store date and time |
| Boolean | Store true / false values |
| Binary | Store binary data |
| Special | Store JSON,UUIDs,etc |
🔢 Numeric Data Types
Used to store numbers.
| Data Type | Description | Range | Example |
|---|---|---|---|
| INT / INTEGER | Whole numbers | -2147483648 to 2147483647 | 10, -5 |
| SMALLINT | Smaller range integers | -32768 to 32767 | 32000 |
| TINYINT | Very small integers | 0 to 255 | 124 |
| BIGINT | Very large integers | -9223372036854775808 to 9223372036854775807 | 9000 |
| DECIMAL(p,s) | Exact decimal values | Custom range | DECIMAL(5,2) |
| FLOAT / DOUBLE | Approximate decimal values | -3.4E+38 to 1.7E+38 | 98.76 |
🔤 Character / String Data Types
Used to store text.
| Data Type | Description | Example |
|---|---|---|
| CHAR(n) | Fixed-length string | CHAR(5) → 'Amit ' |
| VARCHAR(n) | Variable-length string | VARCHAR(20) → 'Rahul' |
| TEXT | Large text data | Description, comments |
| NVARCHAR(n) | Unicode variable-length string (Hindi) | NVARCHAR(20) → 'राहुल' |
| NCHAR(n) | Unicode fixed-length string (Hindi) | NCHAR(5) → 'राहुल' |
| LONGTEXT | Large text data (Unicode) | Description, comments |
Hinglish Tip 🗣: >
CHARfixed size leta hai,VARCHARsirf jitna text ho utna hi space use karta hai.
📅 Date & Time Data Types
Used to store dates and time values.
| Data Type | Description | Range | Example |
|---|---|---|---|
| DATE(YYYY-MM-DD) | Stores date | 1000-01-01 to 9999-12-31 | 2026-01-07 |
| TIME(HH:MM:SS) | Stores time | 00:00:00 to 23:59:59 | 14:30:00 |
| DATETIME(YYYY-MM-DD HH:MM:SS) | Date and time | 1000-01-01 00:00:00 to 9999-12-31 23:59:59 | 2026-01-07 14:30 |
| TIMESTAMP(YYYY-MM-DD HH:MM:SS) | Auto-updated date & time according to zone | 1970-01-01 00:00:01 to 2038-01-19 23:59:59 UTC | System generated |
| YEAR | Stores year | 1901 to 2155 | 2026 |
| CURRENT_DATE | Current date | System generated | System generated |
| CURRENT_TIME | Current time | System generated | System generated |
| CURRENT_TIMESTAMP/NOW | Current date & time | System generated | System generated |
✅ Boolean Data Type
Used to store true or false values.
| Data Type | Description | Stored As |
|---|---|---|
| BOOLEAN / BOOL | Logical true or false | TRUE / FALSE |
| BIT | Binary 1 or 0 | 0 / 1 |
Binary Data Types
Used to store binary data like images, files, etc.
| Data Type | Description | Stored As |
|---|---|---|
| BLOB | Binary large object | Binary data file,image etc |
| BINARY | Fixed-length binary data | Binary data |
Special Data Types
| Data Type | Description | Example |
|---|---|---|
| ENUM | Stores a set of possible values | Enum('red', 'green', 'blue') |
| GEOMETRY | Stores geometric data | POINT(1 2) |
| JSON | Stores key value data | {"name": "Rahul"} |
| XML | Stores Markup data | <h1>Rahul</h1> |
| UUID | Stores unique identifier | UUID() |