contentintech
Databases

MySQL

Inspect schemas, query rows and reason about transactions.

Connect and inspect

mysql -h localhost -u app -pPrompt for the password rather than putting it in shell history
SHOW DATABASES;List databases visible to your account
USE app;Choose the default database
SHOW CREATE TABLE users;Inspect the complete table definition

Read data

SELECT id, name FROM users ORDER BY id LIMIT 20;Fetch a predictable page
SELECT role, COUNT(*) FROM users GROUP BY role;Count users per role
SELECT * FROM users WHERE name LIKE 'A%';Match a string prefix
EXPLAIN SELECT * FROM users WHERE email = 'ada@example.com';Inspect the chosen access path

Transactions and indexes

START TRANSACTION;Begin a transaction on transactional tables
COMMIT;Persist the current transaction
ROLLBACK;Undo uncommitted changes
SHOW INDEX FROM users;Inspect indexed columns and uniqueness

Section navigation