Lesson 1.4 · Reading time: ~8 min
Data types define what kind of values each column can store in a relational database. In this lesson, you will learn the most common SQL data types, when to use each of them, and how correct type choices improve data quality, storage efficiency, and query performance.
In the previous lesson, we covered tables, keys, constraints, and ACID. Now we move to a practical design decision you make for every table: choosing the right data type for each column.

Before diving into subtypes, here are the main SQL data type groups:
TINYINT, INT, BIGINT, DECIMAL, FLOATCHAR, VARCHAR, TEXTDATE, TIME, DATETIME, TIMESTAMPBOOLEAN, BLOB, JSONNumeric data types store numbers, but not all numbers should be stored the same way. In practice, you choose between:
Integer types store whole numbers without decimal places.
| Type | Typical size | Approximate signed range |
|---|---|---|
TINYINT | 1 byte | -128 to 127 |
SMALLINT | 2 bytes | -32,768 to 32,767 |
INTEGER / INT | 4 bytes | -2,147,483,648 to 2,147,483,647 |
BIGINT | 8 bytes | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
The exact ranges can vary slightly by database and by signed/unsigned support.
DECIMAL stores exact values with fixed precision.
DECIMAL(p, s) means:p = total number of digits,s = digits after the decimal point.DECIMAL(10, 2) supports values up to 99,999,999.99.Floating-point types store approximate values.
DOUBLE generally offers higher precision than FLOAT.Text types differ mainly by length behavior and storage strategy.
CHAR(10) always reserves space for 10 characters.VARCHAR(255) stores up to 255 characters but uses only the needed space.Temporal types should be used for any value representing a date, a time, or an event timestamp.
Stores only year-month-day.
Stores only hour-minute-second.
Stores both date and time.
TIMESTAMP may have timezone-aware behavior in some systems, while DATETIME is often timezone-neutral. Always verify your DBMS behavior before designing audit or event tables.
Many relational databases also support useful specialized types:
BOOLEAN: stores true/false values.BLOB: stores binary content such as images or files.JSON: stores semi-structured JSON documents and often supports JSON functions/indexes.Use this practical checklist:
DECIMAL for money; avoid FLOAT for financial amounts.VARCHAR over CHAR unless data length is truly fixed.Choosing data types carefully at design time reduces future data migration work, application bugs, and performance regressions.
Key takeaways from this lesson:
CHAR, VARCHAR, and TEXT should be chosen based on expected text length and storage behavior.DATE, TIME, or TIMESTAMP instead of plain text.DECIMAL stores exact values and is best for money. FLOAT stores approximate values and may introduce rounding differences, so it is better for scientific-style calculations.
In most cases, use VARCHAR because names and emails have variable length. CHAR is better for fixed-length values like country codes.
No. NULL means a missing or unknown value. It is not a separate data type but a special marker that can appear in columns, depending on constraints.
Estimate the expected value range and pick the smallest type that safely fits it. This improves storage efficiency while preventing overflow.
Because DECIMAL stores exact precision and avoids floating-point rounding errors that can cause financial inaccuracies.
Typical issues include incorrect sorting/filtering, conversion errors, wasted storage, slower queries, and inconsistent application logic.