DEV Community

Mads Hansen
Mads Hansen

Posted on

A ChatGPT database query should not jump straight to SQL

A ChatGPT database query should not jump straight from prompt to production SQL.

That shortcut works in demos.

It fails when:

  • the question is ambiguous
  • the schema is messy
  • the tenant scope is missing
  • the result is too broad
  • the answer affects a business decision

A safer workflow has a few steps:

  1. Provide scoped schema context.
  2. Use read-only roles by default.
  3. Generate a query plan before execution.
  4. Ask for clarification when scope is missing.
  5. Return a result contract, not just rows.
  6. Preserve provenance into the final answer.
  7. Audit the full chain.

The final answer should know where the number came from, how fresh it is, what filters were used, and whether the result was truncated.

Longer version: ChatGPT database query workflows

Natural language is the interface. Governance is the system.

Top comments (0)