SQL Data Types Explained with Examples
SQL data types tell the database what kind of data a column can store. They control how values are saved and processed. As a result, choosing the right data type keeps your database fast and reliable.
What Are SQL Data Types
SQL data types specify the type of value that a column must hold.
In a table each column has one data type.
However, names are a text data type. For example,
In addition, ages and prices are both defined to be numeric types.
Numeric Data Types
Numeric data types only store numbers.
With this in mind, they are preferable for counts, prices and totals.
| Data Type | Example | Use |
|---|---|---|
| INT | 25 | Whole numbers |
| BIGINT | 9876543210 | Large numbers |
| DECIMAL(5,2) | 99.50 | Exact decimals |
| FLOAT | 12.75 | Approximate decimals |
Example
CREATE TABLE products (
id INT,
price DECIMAL(6,2),
stock INT
);
String Data Types
String data types hold text values.
You will generally use them for names, emails, titles.
| Data Type | Example | Use |
|---|---|---|
| CHAR(5) | Hello | Fixed length text |
| VARCHAR(50) | Rahul Verma | Variable length text |
| TEXT | Long description | Large text |
Example
CREATE TABLE users (
name VARCHAR(30),
email VARCHAR(50),
bio TEXT
);
Date and Time Data Types
The data types for date and time store values derived from a time based representation.
So they are suitable for dates, timestamps, and schedules.
| Data Type | Example | Use |
|---|---|---|
| DATE | 2026-01-20 | Date only |
| TIME | 10:30:00 | Time only |
| DATETIME | 2026-01-20 10:30:00 | Date and time |
| TIMESTAMP | 2026-01-20 10:30:00 | Tracks time |
Example
CREATE TABLE orders (
id INT,
order_date DATE,
order_time TIME
);
Boolean Data Type
The data type booleans are used to hold empty or true values.
Thus they are exactly perfect for a yes or no type fields.
| Data Type | Example | Use |
|---|---|---|
| BOOLEAN | TRUE | Yes or no |
Example
CREATE TABLE tasks (
title VARCHAR(50),
completed BOOLEAN
);
How to Choose the Right SQL Data Type
First, choose the data type that matches the data that you want to store.
Secondly, use numbers for counts and totals.
Next, require text for names and descriptions.
Lastly use date types for all other time relevant values.
Helps you to keep your database simple and manageable.
Summary
SQL datatypes determine how data is stored in a table.
As they prevent invalid values, they lead to fewer errors.
Learning SQL data types, then writing queries becomes easier.
Check out our resources!
- Bootstrap Templates: Explore our Bootstrap Projects section.
- Free E-Books: Download your Free E-Books here.


