Keep this cheat sheet handy while you practise. These are the commands data analysts type dozens of times a day, grouped by what they act on.
Key Points
- Databases: SHOW DATABASES; CREATE DATABASE db; USE db; DROP DATABASE db;
- Tables: SHOW TABLES; DESCRIBE t; CREATE TABLE …; ALTER TABLE …; DROP TABLE t;
- Read data: SELECT cols FROM t WHERE … ORDER BY … LIMIT n;
- Write data: INSERT INTO t VALUES (…); UPDATE t SET … WHERE …; DELETE FROM t WHERE …;
- Users: CREATE USER, GRANT, REVOKE, SHOW GRANTS
- Help: EXPLAIN query; SHOW PROCESSLIST; SELECT VERSION();
.png)