MySQL Cheat Sheet
Essential MySQL commands for connecting, writing SQL, managing indexes, and choosing storage engines and data types for reliable relational apps.
2 PagesIntermediateMar 5, 2026
Connecting & Basics
CLI connection and schema browsing.
sql
mysql -u root -pSHOW DATABASES;USE mydb;SHOW TABLES;DESCRIBE users;SOURCE dump.sql; -- run a .sql file
SQL Essentials
Core DDL and DML statements.
sql
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB;INSERT INTO users (email) VALUES ('a@b.com');SELECT * FROM users WHERE email LIKE '%example%';UPDATE users SET email = 'x@y.com' WHERE id = 1;DELETE FROM users WHERE id = 1;
Indexes & EXPLAIN
Adding indexes and inspecting execution plans.
sql
CREATE INDEX idx_email ON users(email);ALTER TABLE users ADD INDEX idx_created (created_at);SHOW INDEX FROM users;EXPLAIN SELECT * FROM users WHERE email = 'a@b.com';
Storage Engines & Types
Engine choices and common column types.
- InnoDB- default engine; supports transactions, foreign keys, row-level locking
- MyISAM- legacy engine; no transactions, table-level locks only
- VARCHAR(n)- variable-length string up to n characters
- TEXT- large variable-length string, stored off-row
- DECIMAL(p,s)- exact fixed-precision numeric type
- JSON- native JSON column type with validation (5.7+)
- ENUM- string restricted to a fixed, predefined list of values
Pro Tip
Stick with InnoDB (the default since 5.5) for new tables — it gives you row-level locking, foreign keys, and crash recovery, while MyISAM offers none of those and is effectively legacy.
Was this cheat sheet helpful?
Explore Topics
#MySQL#MySQLCheatSheet#Database#Intermediate#ConnectingBasics#SQLEssentials#IndexesEXPLAIN#StorageEnginesTypes#Databases#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance