SwadhyAI Notes

All SQL notes

🛠️SQL editor

Client ergonomics matter

Your editor and SQL client shape productivity: formatting, execution plans, safe LIMIT defaults, and connection coloring prevent accidents. This is workflow ergonomics, not relational theory, but good tools encourage parameterized queries and schema browsing that reduce SQL injection and typos.

Clients differ in how they batch statements, show locks, and stream results, know yours before tuning timeouts. Standardize read-only roles in shared clients; color production connections red universally.

For interactive practice, use a local client (psql, DBeaver, Azure Data Studio) or a hosted playground connected to a disposable database. Always run destructive experiments inside transactions you can roll back.

🔁Disposable scratch session

Nothing persists after ROLLBACK.

BEGIN;
CREATE TEMP TABLE scratch(x int);
INSERT INTO scratch VALUES (1),(2),(3);
SELECT * FROM scratch;
ROLLBACK;  -- nothing persisted

🧰Tools teams pick

Pick one primary client per role and learn its plan view.

ToolWhy teams pick it
psqlScriptable, \timing, \gx plans
DBeaver / DataGripER diagrams, multi-engine

Client accidents

  • Running whole migration files without transactions where supported.
  • Copying query results with hidden row limits into decisions.
  • Mixing personal credentials in shared jump boxes.

Guardrails

  • Turn on confirm-execute for destructive keywords in production profiles.
  • Keep snippets for EXPLAIN ANALYZE templates per engine.
  • Use formatters and linters in CI for checked-in SQL.
  • Bind parameters in application code, not only in the GUI.

Pools and timeouts

The same SQL text can behave differently through a pooler or GUI batch mode, confirm whether multiple statements run in one round trip and how cancellation is surfaced.

TL;DR

SQL clients (GUIs, CLIs, IDE plugins) send text to the server, show plans and timings, and control transactions. Use them with read-only profiles for production, explicit BEGIN/COMMIT for multi-step changes, and formatters/linters so saved snippets match what ships in migrations. Never paste untrusted SQL, parameterized app code is the real boundary for injection defense.