MySQL + SQL · Lesson 34
MySQL Data Types
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.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.