Chapter 13 — Further Reading

Official reference (everyone)

  • PostgreSQL Docs: "INSERT," "UPDATE," "DELETE," "TRUNCATE." The authoritative syntax, including RETURNING, ON CONFLICT, UPDATE ... FROM, and DELETE ... USING. https://www.postgresql.org/docs/current/sql-insert.html
  • PostgreSQL Docs: "INSERT ... ON CONFLICT" (upsert) and "MERGE" (v15+). The two ways to do insert-or-update; MERGE is the SQL-standard form.
  • PostgreSQL Docs: "Data Manipulation" tutorial chapter. A gentle overview tying the statements together.

Safety & operations (💻 Developer · 🏗️ DBA)

  • psql AUTOCOMMIT and transaction settings. How to make your shell safe by default (Case Study 1). \set AUTOCOMMIT off, \set ON_ERROR_ROLLBACK on.
  • Articles/postmortems on "the missing WHERE clause." Cautionary tales (some famous) that make the habit stick. Every one is a procedural-defense lesson.
  • "Idempotent data pipelines" writeups. Why upsert + idempotency makes jobs safe to retry (Case Study 2).

Concurrency preview (🔬 CS Student · 🏗️ DBA)

  • "Race conditions" / "check-then-act" in databases. The general class of bug behind Case Study 2; you'll formalize it in Chapter 27 (lost updates, isolation).
  • Transactions intro — read ahead to Chapter 26 if you want the why behind BEGIN/COMMIT/ROLLBACK now.

Performance preview (🏗️ DBA)

  • Bulk loading with COPY (Chapter 31): the fast path for inserting many rows.
  • Batching large UPDATE/DELETE — articles on deleting millions of rows without locking a busy table for too long (ties to Chapters 27–28).

Reference (this book)

  • Appendix C — SQL Quick Reference: DML syntax (INSERT/UPDATE/DELETE/UPSERT).
  • Appendix J — Dialect Differences: RETURNING vs OUTPUT, ON CONFLICT vs ON DUPLICATE KEY vs MERGE.

Do, don't just read

  • Practice the safe sequence on Mercado (preview SELECTBEGIN → change → verify → ROLLBACK). Make it muscle memory before you ever touch production.
  • Reproduce Case Study 2's race conceptually: two BEGINs in two psql windows inserting the same sku; watch the unique constraint fire; then fix it with ON CONFLICT.
  • Turn AUTOCOMMIT off in a practice session and feel how every change now waits for your COMMIT.

Next: Chapter 14 — Data Definition: CREATE, ALTER, DROP — building well-constrained tables.