MySQL data types are grouped intoΒ 3 main categories:
πΉ 1. Numeric Data Types
(A) Integer Types
Type |
Storage |
Range (Signed) |
Example |
TINYINT |
1 byte |
-128 to 127 |
Age, flags |
SMALLINT |
2 bytes |
-32,768 to 32,767 |
Small counts |
MEDIUMINT |
3 bytes |
-8M to 8M |
Larger counts |
INT / INTEGER
|
4 bytes |
-2B to 2B |
IDs, counts |
BIGINT |
8 bytes |
Very large numbers |
Banking, population |
π Add UNSIGNED
for positive only.
(B) Decimal Types
Type |
Description |
DECIMAL(M,D) / NUMERIC
|
Exact fixed-point (e.g., DECIMAL(10,2) for money = 12345678.90) |
FLOAT |
4-byte approximate decimal (single precision) |
DOUBLE / REAL
|
8-byte approximate decimal (double precision) |
(C) Bit Type
πΉ 2. Date and Time Data Types
Type |
Format |
Range |
Example |
DATE |
YYYY-MM-DD |
1000-01-01 β 9999-12-31 |
2025-08-21 |
DATETIME |
YYYY-MM-DD HH:MM:SS |
Full date + time |
2025-08-21 10:30:00 |
TIMESTAMP |
YYYY-MM-DD HH:MM:SS |
1970-01-01 UTC β 2038 |
Auto-updates on row changes |
TIME |
HH:MM:SS |
-838:59:59 β 838:59:59 |
12:45:30 |
YEAR |
YYYY |
1901 β 2155 |
2025 |
π TIMESTAMP
is timezone aware, DATETIME
is not.
πΉ 3. String (Character) Data Types
(A) Fixed / Variable Length
Type |
Description |
CHAR(M) |
Fixed-length (padded with spaces). Fast lookup. |
VARCHAR(M) |
Variable-length, up to 65,535 bytes. Common for names, emails. |
(B) Text Types
Type |
Storage |
Max Length |
TINYTEXT |
1 byte |
255 chars |
TEXT |
2 bytes |
65,535 chars |
MEDIUMTEXT |
3 bytes |
16 million chars |
LONGTEXT |
4 bytes |
4 billion chars |
π Use TEXT
for long descriptions.
(C) Blob Types (Binary Large Objects)
Type |
Max Size |
Use Case |
TINYBLOB |
255 B |
Small files |
BLOB |
65 KB |
Images, docs |
MEDIUMBLOB |
16 MB |
Larger files |
LONGBLOB |
4 GB |
Huge files |
(D) Other String Types
-
ENUM('val1','val2',...)
β Fixed list of values.
gender ENUM('M','F','Other')
-
SET('a','b','c')
β Store multiple values from predefined list.
β
Quick Summary
-
Numeric β
INT
, BIGINT
, DECIMAL
, FLOAT
, DOUBLE
.
-
Date/Time β
DATE
, DATETIME
, TIMESTAMP
, TIME
, YEAR
.
-
String β
CHAR
, VARCHAR
, TEXT
, BLOB
, ENUM
, SET
.