Choose the right MySQL column type
MySQL and MariaDB provide integer, fixed and floating-point, string, binary, date/time and JSON types, each with its own storage cost and range. This reference lets you search those types by name or range and filter by category, so you can size each column correctly. It runs entirely in your browser.
How it works
Each entry shows the type, its category, the on-disk storage size and the value
range, plus a note for types whose behaviour depends on time zone or SQL mode.
Integer types come in five widths from TINYINT (1 byte) to BIGINT (8 bytes)
and may be UNSIGNED. String and binary types split into inline CHAR/VARCHAR
and off-page TEXT/BLOB families. A typical table uses several:
CREATE TABLE orders (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
total DECIMAL(12,2) NOT NULL,
status ENUM('new','paid','shipped') NOT NULL,
created DATETIME NOT NULL,
payload JSON
);
Tips and examples
- Prefer the smallest integer type that fits expected values — narrower columns mean smaller indexes and faster scans.
VARCHAR(255)was historically common because of an index-prefix limit; with modernutf8mb4and larger key lengths you can size it to the real maximum.- Add
UNSIGNEDto auto-increment primary keys to double the available id space. - When ordering by a
TEXT/BLOBcolumn you must specify a prefix length on the index, e.g.INDEX (body(100)).