MySQL groups data types into numeric, string, and date/time families. Here are the most commonly used:
-- Numeric
INT -- 4-byte integer (-2B to 2B), use UNSIGNED to double the positive range
BIGINT -- 8-byte integer for large IDs or counters
DECIMAL(p,s) -- exact fixed-point (use for money, e.g. DECIMAL(10,2))
FLOAT/DOUBLE -- approximate floating point (avoid for money)
-- String
CHAR(n) -- fixed-length string, padded with spaces (fast for codes)
VARCHAR(n) -- variable-length string up to n chars
TEXT -- up to 65 535 bytes of text (no default value allowed)
MEDIUMTEXT -- up to 16 MB
LONGTEXT -- up to 4 GB
-- Date & Time
DATE -- '2025-01-19'
DATETIME -- '2025-01-19 14:30:00'
TIMESTAMP -- like DATETIME but stored in UTC and auto-converts to session timezone
TIME -- '14:30:00'
-- Boolean
TINYINT(1) -- MySQL has no native BOOL; 0 = false, 1 = true
Always use utf8mb4 as your character set (not the older utf8) to support full Unicode including emoji:
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
body MEDIUMTEXT,
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;