SQL Data Types Explained for Beginners with Examples
Learn SQL data types from scratch with simple examples. Understand INT, VARCHAR, DATE, DECIMAL, BOOLEAN, and how to choose the right data type in SQL.

SQL Data Types Explained for Beginners with Simple Examples
Welcome to Chapter 2 of our SQL for Beginners series!
In the previous chapter, we learned what SQL is, what databases are, how DBMS works, and how information is stored inside database tables.
Now, let's understand another important concept: SQL Data Types.
Whenever we create a database table, we need to define what kind of information each column will store. For example, an employee's name contains text, age contains a number, and joining date contains a date.
SQL data types help us define exactly what kind of values a column can store.
In this chapter, we will learn different SQL data types using simple explanations and practical examples.
What Are SQL Data Types?
SQL data types define the type of data that can be stored in a database table column. For example, consider an employee table:
ID | Name | Age | Salary | Joining Date |
1 | Rahul | 25 | 40000.50 | 2025-01-10 |
2 | Priya | 28 | 45000.00 | 2025-02-15 |
3 | Amit | 26 | 38000.75 | 2025-03-20 |
Here:
- ID stores numbers.
- Name stores text.
- Age stores whole numbers.
- Salary stores decimal values.
- Joining Date stores date information.
Each column uses a suitable data type.
In simple words: A data type tells the database what kind of information it should expect in a column.
Types of SQL Data Types
SQL data types are generally divided into different categories.
The most commonly used categories are:
- Numeric Data Types
- String Data Types
- Date and Time Data Types
- Boolean Data Types
- Binary Data Types
Let's understand each one.
1. Numeric Data Types
Numeric data types are used to store numbers.
They are useful for employee IDs, ages, product quantities, prices, salaries, and other numerical values. Some commonly used numeric data types include:
Data Type | Description | Example |
INT | Stores whole numbers | 100 |
SMALLINT | Stores smaller-range whole numbers | 25 |
BIGINT | Stores large whole numbers | 9876543210 |
DECIMAL(p,s) | Stores exact decimal values | 1250.50 |
FLOAT | Stores approximate decimal values | 25.75 |
DOUBLE | Stores approximate decimal values with greater precision | 12345.6789 |
Example: INT
The INT data type is commonly used to store whole numbers.
CREATE TABLE students (
student_id INT,
age INT
);Here, student_id and age store integer values.
Example: DECIMAL
DECIMAL is useful when we need accurate decimal values, especially for financial information.
CREATE TABLE products (
product_id INT,
product_price DECIMAL(10,2)
);Here:
- 10 represents the maximum total number of digits.
- 2 represents the number of digits after the decimal point.
For example, 12500.50 can be stored in this column.
2. String Data Types
String data types are used to store text, names, email addresses, descriptions, and other character-based information.
Some commonly used string data types are:
Data Type | Description | Example |
CHAR(n) | Fixed-length text | 'INDIA' |
VARCHAR(n) | Variable-length text | 'Rahul' |
TEXT | Stores longer text | Blog description |
Example: CHAR
CHAR stores fixed-length character values.
CREATE TABLE countries (
country_code CHAR(3),
country_name VARCHAR(100)
);For example, a country code such as IND can be stored in CHAR(3).
Example: VARCHAR
VARCHAR is one of the most commonly used SQL data types.
It stores variable-length text.
CREATE TABLE users (
user_id INT,
username VARCHAR(50),
email VARCHAR(100)
);Here:
- username can store up to 50 characters.
- email can store up to 100 characters.
CHAR vs VARCHAR
CHAR | VARCHAR |
Fixed-length character storage | Variable-length character storage |
Suitable for fixed-size values | Suitable for names and emails |
Example: CHAR(3) | Example: VARCHAR(100) |
3. Date and Time Data Types
Date and time data types are used to store dates, times, and timestamps. They are useful for employee joining dates, order dates, registration dates, and transaction records.
Common date and time data types include:
Data Type | Description | Example |
DATE | Stores date | 2026-11-02 |
TIME | Stores time | 14:30:00 |
DATETIME | Stores date and time | 2026-11-02 14:30:00 |
TIMESTAMP | Stores a date and time value | 2026-11-02 14:30:00 |
Example
CREATE TABLE employees (
employee_id INT,
employee_name VARCHAR(100),
joining_date DATE,
created_at DATETIME
);Here:
- joining_date stores the employee's joining date.
- created_at stores the date and time when a record was created.
4. Boolean Data Type
A Boolean represents a logical value:
- TRUE
- FALSE
It is useful for storing information such as:
- Whether a user is active.
- Whether an order is completed.
- Whether a product is available.
Example
CREATE TABLE users (
user_id INT,
username VARCHAR(50),
is_active BOOLEAN
);Example records:
user_id | username | is_active |
1 | Rahul | TRUE |
2 | Priya | FALSE |
Note: Boolean implementation differs between database systems. For example, MySQL treats BOOLEAN as a synonym for TINYINT(1), while PostgreSQL has a native BOOLEAN type.
5. Binary Data Types
Binary data types are used to store binary information rather than ordinary text. They can be useful for storing files, images, documents, and other binary content.
Some common binary data types include:
Data Type | Description |
BINARY | Fixed-length binary data |
VARBINARY | Variable-length binary data |
BLOB | Stores binary large objects |
Example
CREATE TABLE documents (
document_id INT,
document_data BLOB
);Here, document_data can store binary file content.
In many applications, files are stored in the cloud or file storage, while their URLs or references are stored in the database.
Practical Example: Creating an Employee Table
Now let's combine what we have learned. Suppose we want to create an employee table containing employee details.
CREATE TABLE employees (
employee_id INT,
employee_name VARCHAR(100),
age INT,
salary DECIMAL(10,2),
joining_date DATE,
is_active BOOLEAN
);Let's understand the columns:
Column | Data Type | Purpose |
employee_id | INT | Employee ID |
employee_name | VARCHAR(100) | Employee name |
age | INT | Employee age |
salary | DECIMAL(10,2) | Employee salary |
joining_date | DATE | Joining date |
is_active | BOOLEAN | Active status |
This is how SQL data types help us define the structure of a database table.
How to Choose the Right SQL Data Type?
Choosing the correct data type is important when designing database tables.
Here are some simple guidelines:
- Use INT for whole numbers such as IDs and age.
- Use BIGINT when values may exceed the INT range.
- Use VARCHAR for names, emails, and other variable-length text.
- Use DECIMAL for money and other exact decimal values.
- Use DATE for dates without time.
- Use DATETIME or TIMESTAMP when date and time information is required.
- Use BOOLEAN for true/false information where supported.
- Use BLOB for binary content when storing it directly in the database.
Choosing suitable data types helps maintain data consistency and use database storage efficiently.
Common Mistakes Beginners Should Avoid
When learning SQL data types, beginners sometimes make these mistakes:
- Using INT for values that contain decimal points.
- Using VARCHAR for dates instead of a proper DATE column.
- Choosing unnecessarily large VARCHAR lengths.
- Using FLOAT instead of DECIMAL for financial values.
- Forgetting that data type behavior can differ between MySQL, PostgreSQL, SQL Server, and Oracle.
Understanding these differences will help you write better SQL queries and design better databases.
Conclusion
SQL data types are one of the fundamental concepts every SQL beginner should understand. They help databases identify what kind of information each column can store, whether it is a number, text, date, Boolean value, or binary information.
In this chapter, we explored numeric, string, date and time, Boolean, and binary data types with practical examples. Keep practicing these concepts because they will be useful when creating real-world database tables.
What Will You Learn Next? In Chapter 3, we will learn how to create databases and tables in SQL using CREATE DATABASE and CREATE TABLE commands.
Stay connected with ApnaInsights to continue your SQL learning journey!
Frequently Asked Questions
What are SQL data types?
SQL data types define the kind of values that can be stored in a database table column, such as numbers, text, dates, and Boolean values.
What is the most commonly used SQL data type?
INT and VARCHAR are among the most commonly used SQL data types. INT stores whole numbers, while VARCHAR stores variable-length text.
What is the difference between CHAR and VARCHAR?
CHAR is designed for fixed-length character values, whereas VARCHAR stores variable-length text.
Version History 2 updates
- Nov 2, 2026
Updated: title, description, content, categories, tags, featuredImage, images, status, faqs, seriesName, seriesOrder, wordCount, readingTimeMinutes, slug, rejectionReason
- Nov 2, 2026
Updated: title, description, content, categories, tags, featuredImage, images, status, faqs, seriesName, seriesOrder, wordCount, readingTimeMinutes, slug, rejectionReason