1. INT – Whole Numbers (No Decimal)
INT is used to store integer values — meaning numbers without any decimal part.
It’s perfect for values like age, quantity, roll numbers, or employee IDs.
Example:
age INT;
The most common and useful data types are as follows:
INT is used to store integer values — meaning numbers without any decimal part.
It’s perfect for values like age, quantity, roll numbers, or employee IDs.
Example:
age INT;
When you need fractional or decimal values, use FLOAT or DOUBLE.
They store numbers like 5.75, 99.99, or 3.14159.
Example:
price FLOAT;
Use VARCHAR when you want to store short to medium-length text such as names, emails, cities, etc. You specify a maximum length (n) to limit how many characters can be stored.
Example:
name VARCHAR(100);
TEXT is for storing long blocks of text, like descriptions, feedback, articles, or reviews. Unlike VARCHAR, TEXT is meant for when you expect a lot of text.
Example:
description TEXT;
The DATE type stores values in YYYY-MM-DD format. It’s best for birthdays, registration dates, join dates, etc.
Example:
birthdate DATE;
DATETIME stores both the date and the exact time. It’s great for recording events like logins, signups, updates, or transactions.
Example:
created_at DATETIME;
BOOLEAN is used when you want to store binary choices – like whether a user is active, an order is delivered, or an option is selected.
Example:
is_active BOOLEAN;
ENUM lets you limit a column to a predefined list of possible values. Great for things like gender, user roles, status, or categories.
Example:
gender ENUM('Male', 'Female', 'Other');