Chapter 14: Data and failure

The way you talk to all of this is a language older than most programmers, and it is worth being able to read.

SQL

The language for asking a relational database for things. You describe what you want, such as which rows, in what order and how many, and the database works out how to get it. SELECT reads. INSERT, UPDATE and DELETE change. It looks like English, and small mistakes in it can be enormous.

You don't need to write much SQL when an agent writes it for you. You do need to read what it wrote, especially the part after WHERE, because an UPDATE or a DELETE with the wrong condition, or with none, runs without complaint. Ask to see the statement before it runs against anything you care about.

Say it to your agent

“Show me the exact SQL before you run it. For any UPDATE or DELETE, first run a SELECT count(*) with the same WHERE, and tell me how many rows it would change. Wrap it in BEGIN, and don't COMMIT until I say so.”

The workshop

Name a word, or describe what you mean in everyday language.