MySQL Data Types
Every column needs a data type that decides what kind of value it can store. Choosing the right type saves space and prevents errors.
Numeric Types
| Type | Use |
|---|
| INT | Whole numbers (roll_no, age) |
| DECIMAL(8,2) | Exact money values (fees) |
| FLOAT/DOUBLE | Approximate decimals |
String Types
| Type | Use |
|---|
| CHAR(n) | Fixed length (state code) |
| VARCHAR(n) | Variable length (name, email) |
| TEXT | Long text (remarks) |
Date & Time
| Type | Use |
|---|
| DATE | 2026-06-01 |
| DATETIME | Date + time |
| TIMESTAMP | Auto-updated time |
Summary
- Numeric: INT, DECIMAL, FLOAT. String: CHAR, VARCHAR, TEXT. Date: DATE, DATETIME, TIMESTAMP.
- Use DECIMAL for money, VARCHAR for names.