MySQL is an open-source relational database management system (RDBMS) that uses Structured Query Language (SQL) for managing and querying data. As one of the world's most popular database systems, MySQL powers everything from small web applications to large-scale enterprise systems, offering ACID-compliant transactions, replication, and high availability features. MySQL 8.4 is the current Long-Term Support (LTS) release, bringing improvements to JSON handling, window functions, LATERAL derived tables, and role-based access control while removing legacy master/slave replication terminology. A critical distinction to understand: while MySQL supports multiple storage engines, InnoDB (the default since MySQL 5.5) provides row-level locking and foreign key constraints, whereas the legacy MyISAM uses table-level locking—choosing the right engine and understanding isolation levels can make the difference between a responsive system and one plagued by deadlocks.
What This Cheat Sheet Covers
This topic spans 38 focused tables and 306 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Data Types
| Type | Example | Description |
|---|---|---|
id INT PRIMARY KEY | • Integer range -2,147,483,648 to 2,147,483,647 (signed) • 4 bytes. | |
name VARCHAR(100) | • Variable-length string • only uses space needed plus 1–2 bytes for length • max 65,535 chars. | |
description TEXT | • Variable-length string for large text blocks • max 65,535 chars • cannot have a default value or be a primary key. | |
price DECIMAL(10,2) | • Fixed-point number with exact precision • first param = total digits, second = decimal places • ideal for currency. | |
birth_date DATE | • Stores date only in YYYY-MM-DD format• range 1000-01-01 to 9999-12-31. | |
created_at DATETIME | • Stores date and time in YYYY-MM-DD HH:MM:SS• range up to 9999-12-31 23:59:59• not timezone-aware. | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | • Stores datetime with automatic timezone conversion • range 1970-01-01 to 2038-01-19 UTC• auto-updates on modification. | |
is_active BOOLEAN | • Synonym for TINYINT(1) • stores 0 (false) or 1 (true) • MySQL converts TRUE/FALSE to 1/0. | |
user_id BIGINT | • Large integer • 8 bytes • range ±9.2×10¹⁸ • used for large auto-increment IDs and big counts. | |
metadata JSON | • Native JSON type • validates JSON syntax • supports path expressions and indexing via generated columns. | |
status ENUM('pending', 'active', 'closed') | • String with predefined allowed values • stored internally as integers • max 65,535 distinct values. |