Learn With Grito

SQL Data Types
Explained for Beginners

SQL tables store data. But databases need rules for what kind of data can go into each column. That is where SQL data types come in.

Tutorial Series8 Mins ReadSQL Level 4

SQL tables store data. But databases need rules for what kind of data can go into each column. That is where SQL data types come in.

If you are learning SQL for data analysis, interviews, or real projects, understanding SQL data types is essential. Because bad data types create:

  • broken queries
  • incorrect calculations
  • storage inefficiency
  • performance problems
  • reporting errors
  • messy analytics

In this guide, you’ll learn:

  • what SQL data types are
  • why they matter for data analysts
  • the most important SQL data types for beginners
  • real business examples
  • common mistakes
  • interview questions

What Are SQL Data Types?

SQL data types define the kind of data a column can store. Think of them as rules.

Examples:

  • numbers
  • text
  • dates
  • true/false values
  • decimal values
  • timestamps
Example Query
CREATE TABLE customers (
   customer_id INT,
   customer_name VARCHAR(100),
   signup_date DATE
);

Here:

  • customer_id → stores numbers
  • customer_name → stores text
  • signup_date → stores dates

Simple idea: Data types tell the database what kind of values are allowed in a column.

Why SQL Data Types Matter for Data Analysts

Beginners often ignore data types. That becomes painful later. Because analytics depends on correct data structure.

Revenue Analysis

Revenue should be numeric.

Example
-- Correct:
revenue DECIMAL(10,2)

-- Wrong:
revenue VARCHAR(50)

Why? Because text cannot be reliably summed.

Customer Signup Tracking

Example
-- Correct:
signup_date DATE

-- Wrong:
signup_date VARCHAR(20)

Why? Date filtering becomes difficult.

Filtering Example
-- Bad:
WHERE signup_date > 'Jan 5'

-- Good:
WHERE signup_date > '2025-01-05'

Product Availability

Example
-- Correct:
is_active BOOLEAN

This makes logic cleaner.

For analysts: Good schemas make analysis easier. Bad schemas create constant cleanup work.

SQL Data Types Categories

Broadly, SQL data types fall into categories:

  • Numeric
  • Character / String
  • Date / Time
  • Boolean

This article focuses on the beginner essentials:

  • INT
  • VARCHAR
  • DATE
  • BOOLEAN
  • DECIMAL
  • DATETIME

These cover most beginner analytics use cases.

1. INT in SQL

INT stores whole numbers. No decimals.

Examples:

  • customer IDs
  • quantity sold
  • age
  • product counts
  • employee IDs
Example Table
CREATE TABLE orders (
   quantity INT
);

Valid values: 1, 25, 100, 999
Invalid values: 12.5, abc

Real Analyst Example: Order quantity

Analyst Example
CREATE TABLE sales (
   units_sold INT
);
units_sold
5
12
30

Use case: Inventory analysis.

When to Use INT

Use INT for:

  • identifiers
  • counts
  • whole-number metrics
  • quantities

Important: Do NOT use INT for money. That needs decimals.

2. VARCHAR in SQL

VARCHAR stores text. VARCHAR = Variable Character.

Example
customer_name VARCHAR(100)

This means text up to 100 characters. Examples: Rahul, Priya Sharma, Mumbai, Electronics.

Why VARCHAR Matters

Business data is full of text. Examples:

  • names
  • cities
  • product categories
  • emails
  • department names
  • campaign labels

Real Analyst Example: Customer info

Analyst Example
CREATE TABLE customers (
   email VARCHAR(255)
);

VARCHAR vs CHAR

VARCHAR

Variable length. Stores only needed space. (Use this for most analyst cases)

CHAR

Fixed length. Always reserves full size. Even 'Rahul' in CHAR(10) uses full fixed allocation.

3. DATE in SQL

DATE stores calendar dates. No time. Format usually: YYYY-MM-DD.

Example
signup_date DATE

Valid: 2025-01-15, 2024-12-01

Real Analyst Example: Customer signup analysis

Analyst Example
CREATE TABLE customers (
   signup_date DATE
);

SELECT *
FROM customers
WHERE signup_date > '2025-01-01';

Use cases:

  • retention analysis
  • signup trends
  • monthly reporting
  • campaign timing

4. BOOLEAN in SQL

BOOLEAN stores true/false values. Examples: TRUE, FALSE.

Common business examples:

  • active subscription?
  • premium user?
  • verified account?
  • payment completed?

Real Analyst Example: Customer status

Analyst Example
CREATE TABLE users (
   is_premium BOOLEAN
);

SELECT *
FROM users
WHERE is_premium = TRUE;

Database Note: Some databases implement BOOLEAN differently. Examples: TRUE/FALSE or 1/0. Still, conceptually it means yes/no logic.

The Grito Factor A shocking amount of real company data stores dates and numbers as text. Yes—actual revenue columns as VARCHAR. This is why analysts often spend more time cleaning “bad schema decisions” than doing analysis.

5. DECIMAL in SQL

DECIMAL stores exact decimal numbers. Critical for financial calculations.

Example
price DECIMAL(10,2)

Meaning: total digits = 10, decimal places = 2. Examples: 99.99, 1500.50, 12.75.

Why DECIMAL Matters

Money should not use INT. If you use price INT, you lose decimal precision (cents / paise). 99.99 becomes 99.

Real Analyst Example: Revenue table

Analyst Example
CREATE TABLE sales (
   revenue DECIMAL(12,2)
);

SELECT SUM(revenue)
FROM sales;

Use cases:

  • sales analysis
  • revenue dashboards
  • commissions
  • discounts
  • margins

6. DATETIME in SQL

DATETIME stores both date and time. Format example: 2025-06-01 14:30:00.

Why DATETIME Matters

Many analytics questions depend on exact timestamps. Examples:

  • when did the user sign up?
  • when was the order placed?
  • when did checkout happen?
  • when did payment fail?

Real Analyst Example: Orders

Analyst Example
CREATE TABLE orders (
   order_timestamp DATETIME
);

SELECT *
FROM orders
WHERE order_timestamp > '2025-06-01 00:00:00';

Use cases:

  • funnel analysis
  • session analysis
  • hourly reporting
  • event analytics

SQL Data Types Summary Table

Data TypeStoresExample
INTwhole numbers25
VARCHARtextRahul
DATEdates2025-01-15
BOOLEANtrue/falseTRUE
DECIMALexact decimal numbers499.99
DATETIMEdate + time2025-06-01 14:30:00

Real Business Schema Example

This is realistic analytics schema design:

Schema Example
CREATE TABLE customers (
   customer_id INT,
   customer_name VARCHAR(100),
   email VARCHAR(255),
   signup_date DATE,
   is_active BOOLEAN
);

CREATE TABLE orders (
   order_id INT,
   customer_id INT,
   revenue DECIMAL(12,2),
   order_timestamp DATETIME
);

Common Beginner Mistakes

1. Using VARCHAR for Numbers

Bad: salary VARCHAR(50)
Sorting breaks. Text sorting makes '100' come before '20'.

2. Using INT for Money

Bad: price INT
Decimal precision lost.

3. Using VARCHAR for Dates

Bad: order_date VARCHAR(20)
Date calculations and filtering become messy.

4. Choosing Tiny VARCHAR Sizes

Bad: email VARCHAR(10)
Emails exceed that. Data gets rejected or truncated.

5. Ignoring Time When DATETIME Is Needed

Bad: Using DATE for event tracking.
Checkout timing matters. DATE loses hour/minute detail.

SQL Data Types in Interviews

Interviewers test practical understanding. Not memorized definitions.

Common interview questions:

  • What is VARCHAR?
  • Difference between CHAR and VARCHAR?
  • INT vs DECIMAL?
  • DATE vs DATETIME?
  • Why not store revenue as VARCHAR?
  • What does DECIMAL(10,2) mean?
  • What is BOOLEAN?

Practice Questions

  1. What data type should store customer names?
  2. What data type should store product price?
  3. What data type should store signup date only?
  4. What data type should store login timestamp?
  5. What data type should store yes/no account status?

What Comes Next?

After SQL data types, learn SQL constraints (primary keys, foreign keys, NOT NULL, UNIQUE, DEFAULT). Because defining what data is only step one. Next comes defining the rules.

Final Thoughts

SQL data types seem basic. But they shape everything. Good schemas create clean analytics. Bad schemas create constant frustration.

For data analysts, understanding data types helps you:

  • debug data issues
  • write cleaner queries
  • avoid calculation errors
  • think like a real analyst

Master these six first. They cover most beginner SQL work.

Grit Over Excuses.

— The Grito Team