A good human in the loop for AI database operations does not put a person in front of every query to approve it. It asks one question first. Can a human realistically catch this mistake in time? For most database work the honest answer is no. Generated SQL looks correct at a glance, a bad DELETE runs in milliseconds, and a tired reviewer rubber-stamps the tenth migration of the day. So the right design prevents the dangerous outcome instead of reviewing it. You grade each kind of database action by how reversible it is, how wide its blast radius reaches, and how high the stakes are, then you match controls to the grade. A read-only role, scoped credentials granted just in time, a forced dry-run that shows the affected-row count, and verified backups do more to keep your data safe than any approval prompt. This article shows how to build that loop for an AI SQL agent.

The scenario is now common. You have given an agent the ability to query and modify a database: an analytics assistant that writes SQL from natural language, a support bot that updates records, a coding agent that runs migrations. The agent is useful precisely because it acts. A database is one of the least forgiving surfaces an agent can touch, and "let a human approve the SQL" is the control everyone reaches for and the one that fails most quietly.