Back to SQL Notes
Topic #71

SQL Data Types — Numeric, String, Date & Boolean

Every column in a table has a data type that determines what kind of value it can hold and how it's stored, compared, and sorted.

Numeric Types

TypeUse For
INT / INTEGERWhole numbers — IDs, counts, quantities
DECIMAL(p,s) / NUMERIC(p,s)Exact values — money, precise measurements
FLOAT / DOUBLEApproximate decimal values — scientific data (avoid for money)

String Types

TypeUse For
CHAR(n)Fixed-length text — e.g. a 2-letter state code
VARCHAR(n)Variable-length text with a max length — names, emails
TEXTLong, unbounded text — articles, descriptions

Date & Time Types

TypeUse For
DATEJust a date — 2026-08-15
TIMEJust a time — 14:30:00
DATETIME / TIMESTAMPDate and time together

Boolean

MySQL doesn't have a true native BOOLEAN — it's stored as TINYINT(1) (0/1). PostgreSQL and SQL Server support a real BOOLEAN/BIT type.

Example

CREATE TABLE employees (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    salary DECIMAL(10,2),
    is_active BOOLEAN,
    joined_on DATE
);

Dialect Differences

ConceptMySQLPostgreSQLSQL Server
Auto-incrementing IDAUTO_INCREMENTSERIAL / IDENTITYIDENTITY(1,1)
BooleanTINYINT(1)BOOLEANBIT
Long textTEXTTEXTVARCHAR(MAX)

Common Mistakes

  • Using FLOAT for money. Floating-point numbers can't represent values like 0.1 exactly, which causes rounding errors in financial totals — always use DECIMAL for currency.
  • Using VARCHAR(255) for everything out of habit, without thinking about the actual max length needed.
  • Storing dates as strings (e.g. VARCHAR) instead of a real DATE type — you lose the ability to sort and filter correctly.

Interview Relevance

Q: "Why shouldn't you store prices as FLOAT?" is a common one — the answer is binary floating-point representation causing rounding errors; DECIMAL stores exact values.

Practice Question

Choose an appropriate data type for: a phone number, a product price, an "in stock" flag, and a user's date of birth.

Want to go beyond the notes?

Join Coding Now Tech Institute's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

SQL Data Types — Numeric, String, Date & Boolean – FAQs

Quick answers about learning SQL Data Types — Numeric, String, Date & Boolean in SQL.

This free note from Coding Now Tech Institute explains SQL Data Types — Numeric, String, Date & Boolean in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on Coding Now Tech Institute, including SQL Data Types — Numeric, String, Date & Boolean, is 100% free with no signup required.
With focused practice, most students grasp SQL Data Types — Numeric, String, Date & Boolean in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now