Preface
There is a moment, and perhaps you have already lived it, when you ask a large language model to write a SQL query, and it does, without hesitation and with better quality than you were expecting. A window function, a recursive common table expression (CTE), a lateral join that would have taken you twenty minutes of careful thinking: done in seconds. For many practitioners, this moment produces a peculiar mix of relief and unease.
If the machine can do this, you may ask, what exactly am I here for? We wrote much of this book before that question became urgent. But the world shifted under our feet as we wrote, and we owe you an honest account of what that shift means, explaining why it matters more than ever.
Tools like Claude and ChatGPT have done something remarkable: they have made advanced SQL accessible to anyone willing to describe what they need in plain language. The syntax barrier, for so long the wall separating those who could build data systems from those who merely used them, is coming down. Window functions no longer require a ritual of Stack Overflow searches. Complex aggregations no longer demand a specialist. A domain expert who understands the business can now, more than ever before, reach directly into the data.
This is genuinely good and is worth celebrating. But capability without understanding is dangerous. A large language model (LLM) can generate a beautifully structured query that computes the wrong thing, silently, plausibly, and at scale. It can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access