SQL guides
Practical guides for working with PostgreSQL, MySQL, SQLite and SQL Server, with commands you can run.
-
How to connect to a database through an SSH tunnel on Mac
Forward a local port to PostgreSQL or MySQL with ssh -L, keep the tunnel alive, save key passphrases in the Keychain, use jump hosts and fix errors.

-
How to read a PostgreSQL EXPLAIN plan
Read PostgreSQL EXPLAIN and EXPLAIN ANALYZE output line by line, from cost and rows to scan and join types, with a worked example of a slow query and its fix.

-
How to edit production data safely
Habits and settings that stop a bad UPDATE on a live database, from read-only roles and transactions to safe-updates mode, timeouts and real backups.

-
How to copy a table from MySQL to PostgreSQL
Map MySQL column types to PostgreSQL, copy the rows with a TSV export and psql, with pgloader or with a GUI client, then fix sequences and verify the data.
