#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 2
3 min read

Data Types

The 4 types of data you can store in SQL databases.

What are Data Types?

Data types tell the database what kind of information you're storing. Just like you put clothes in a closet and food in a fridge - different data goes in different types.

The 4 Main Data Types

1. Numbers

INTEGER - Whole numbers (no decimals)

age INTEGER -- 20, 25, 30 student_id INTEGER -- 1, 2, 3

DECIMAL - Numbers with decimals (for money!)

price DECIMAL(10,2) -- 19.99, 100.50 salary DECIMAL(10,2) -- 50000.00

2. Text

VARCHAR(size) - Text with max length

name VARCHAR(100) -- "John Smith" email VARCHAR(200) -- "john@email.com"

TEXT - Long text (no limit)

bio TEXT -- Long description content TEXT -- Blog post

3. Date & Time

birth_date DATE -- 2000-05-15 login_time TIME -- 09:30:00 created_at TIMESTAMP -- 2024-11-19 10:30:00

4. True/False

BOOLEAN - Yes or No values

is_active BOOLEAN -- TRUE or FALSE is_verified BOOLEAN -- TRUE or FALSE

Quick Guide: Which Type to Use?

Storing ages, counts, IDs?INTEGER

Storing money or prices?DECIMAL(10,2)

Storing names, emails?VARCHAR(100)

Storing long text?TEXT

Storing dates?DATE or TIMESTAMP

Storing yes/no?BOOLEAN

Real Example

CREATE TABLE users ( id INTEGER, name VARCHAR(100), email VARCHAR(200), age INTEGER, salary DECIMAL(10,2), is_active BOOLEAN, created_at TIMESTAMP );

Tip: Always use DECIMAL for money (not FLOAT) - it's more accurate!

See Data Types in Action

name is VARCHAR (text), age is INTEGER (number), grade is CHAR (single letter)

SQL Editor
Loading...
Output

Click "Run Query" to see results

Finished this topic?

Mark it complete to track your progress and maintain your streak!