Skip to content
Learn Netverks

Lesson

Step 7/36 19% through track

data-types-mysql

MySQL data types

Last reviewed Jun 1, 2026 Content v20260601
Track mode
sql_sandbox
Means
SQL sandbox
Reading
~1 min
Level
beginner

This lesson

This lesson teaches MySQL data types: the SQL patterns, schema habits, and query reasoning you need before advancing in MySQL.

Teams query MySQL data types on every MySQL codebase—skipping it leaves gaps in debugging and data reviews.

You will apply MySQL data types in contexts like: Web apps on shared hosting, ecommerce, and many startups’ first production DB.

Copy MySQL SQL into the mysql client, local MySQL/MariaDB, or DB Fiddle (MySQL dialect)—use DESCRIBE and EXPLAIN where lessons show them. The in-browser lab ships later; mysql client is the practice path now.

When you can explain the previous lesson's ideas without copying example queries verbatim.

Pick types for range and storage: INT/BIGINT, DECIMAL for money, DATETIME vs TIMESTAMP, JSON, TEXT.

Common types

  • INT, BIGINT — integers; UNSIGNED if non-negative only
  • DECIMAL(p,s) — exact money (avoid FLOAT for currency)
  • VARCHAR(n), TEXT — strings; VARCHAR for indexed shorter fields
  • DATETIME, TIMESTAMP — TIMESTAMP is UTC storage with session TZ display
  • JSON — validated JSON documents (5.7+)

Examples

CREATE TABLE ledger (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  amount DECIMAL(12,2) NOT NULL,
  posted_at DATETIME NOT NULL,
  meta JSON
);

Practice: Run on database practice in mysql client.

BOOLEAN

BOOLEAN is alias for TINYINT(1)—0/1 in practice.

Important interview questions and answers

  1. Q: FLOAT for money?
    A: Rounding errors—use DECIMAL or integer cents.
  2. Q: TIMESTAMP vs DATETIME?
    A: TIMESTAMP converts to UTC; DATETIME stores literal value.

Self-check

  1. Which type for exact currency?
  2. What is BOOLEAN under the hood?

Tip: DECIMAL for money; avoid FLOAT currency.

Interview prep

Money type?

DECIMAL(p,s)—not FLOAT for currency.

BOOLEAN?

Alias for TINYINT(1).

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • DECIMAL money?
  • TIMESTAMP vs DATETIME?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump