✏️ Explanatory Question
Level: Advanced — A must-know comparison; InnoDB is the modern default for very good reasons.
MySQL supports pluggable storage engines — the underlying software that handles how data is stored and retrieved. The two most famous are InnoDB (the default since MySQL 5.5) and MyISAM (the older, legacy engine).
| Feature | InnoDB | MyISAM |
|---|---|---|
| Transactions (ACID) | Yes | No |
| Foreign keys | Yes | No |
| Locking level | Row-level | Table-level |
| Crash recovery | Strong (redo logs) | Weak (can corrupt) |
| Concurrency | High | Low (table locks) |
| Full-text search | Yes (5.6+) | Yes |
| Best for | Write-heavy, OLTP, concurrency | Read-heavy, simple apps |
-- Specify the engine when creating a table
CREATE TABLE orders (
id INT PRIMARY KEY,
amount DECIMAL(10,2)
) ENGINE = InnoDB;
-- Legacy MyISAM table
CREATE TABLE logs (
id INT PRIMARY KEY,
msg TEXT
) ENGINE = MyISAM;
-- Check the engine of existing tables
SHOW TABLE STATUS WHERE Name = 'orders';
-- Convert an existing table to InnoDB
ALTER TABLE logs ENGINE = InnoDB;