MySQL Data Types Explained — Which to Use and When

Choosing the right data type for each column is one of the most important decisions in database design. The wrong choice costs you storage, hurts query performance, and can introduce subtle data integrity bugs. This guide covers the most important MySQL data types and when to reach for each one.

Numeric Types

TypeStorageRange (signed)Use for
TINYINT1 byte-128 to 127Booleans, small status flags
SMALLINT2 bytes-32,768 to 32,767Small counters, age, year
INT4 bytes-2.1B to 2.1BGeneral-purpose IDs and counts
BIGINT8 bytes±9.2 quintillionHigh-volume tables, snowflake IDs
DECIMAL(p,s)VariableExactMoney, measurements requiring precision
FLOAT / DOUBLE4 / 8 bytesApproximateScientific values where small errors are acceptable

Key rules:

String Types

TypeMax sizeUse for
CHAR(n)255 charsFixed-length strings: country codes, hashes, status enums
VARCHAR(n)65,535 bytesVariable-length strings: names, emails, URLs, titles
TEXT65,535 bytesLong content: descriptions, comments, HTML
MEDIUMTEXT16 MBLarge documents, article bodies
LONGTEXT4 GBVery large content (logs, serialised data)

Key rules:

Date and Time Types

TypeRangeUse for
DATE1000-01-01 to 9999-12-31Dates without time: birthdays, deadlines
DATETIME1000-01-01 to 9999-12-31Timestamps stored in application timezone
TIMESTAMP1970-01-01 to 2038-01-19Audit timestamps stored in UTC, auto-converted on retrieval
TIME-838:59:59 to 838:59:59Durations, time-of-day without date
YEAR1901 to 2155Year-only values

Key rules:

JSON Type

MySQL 5.7+ supports a native JSON column type that validates JSON on insert and enables path-based queries with JSON_EXTRACT() and the -> operator.

SELECT config->'$.theme' FROM user_settings WHERE user_id = 1;

Use JSON for truly variable or schema-less data — feature flags, user preferences, integration payloads. Don't use it as a way to avoid modelling your data properly: if the same key appears in every row, it should be a column.

A Quick Reference: Common Use Cases

Apply these data types in your schema

SQL Designer lets you pick MySQL data types from a dropdown as you design your tables visually. Free, no installation required.

Create a Free Account