Lighting the Way to AIExact recipes for real AI jobsHome

learn · ~25 min

Turn a pasted schema and a plain-English goal into SQL—without inventing tables, and with a warning before anything destructive.

Last verified: 2026-09-07

Read-only by default. The model must not invent tables or columns. Every answer needs an ASSUMPTIONS list. Never run destructive SQL blind—DELETE / UPDATE / DROP / TRUNCATE / ALTER needs a warning, ALLOW DESTRUCTIVE, a preview SELECT, and a backup you control.

Top picks

Best Overall

Claude

Careful with “only columns I pasted.”

Open Claude

Best Free

ChatGPT Free

Enough for one careful paste-and-review session.

Open ChatGPT

Best Power-User

Gemini + your SQL console

Draft here; run EXPLAIN in your own warehouse.

Open Gemini

Protocol

  1. Paste schema, dialect, and the question (4 min).

    Include dialect (PostgreSQL, MySQL, BigQuery, SQL Server, SQLite), CREATE TABLE or a column list, grain/keys if you know them, and the question in one sentence. If a table is not in the paste, it does not exist for this chat.

  2. Lock “never invent schema.”

    Paste the rules before the schema so the model cannot hallucinate a users.email column.

    Copy-paste prompt

    Write SQL from a schema and a plain-English goal I will paste.
    
    Hard rules:
    - Use only tables and columns in my schema paste. Never invent a table, column, type, or join key.
    - If the goal needs a column I did not give, stop and list NEED FROM SCHEMA. Do not guess.
    - Default to a read-only SELECT (or WITH … SELECT).
    - Before any DELETE, UPDATE, DROP, TRUNCATE, MERGE, or ALTER: print a WARNING block (what rows/objects, what is irreversible) and wait for me to type ALLOW DESTRUCTIVE.
    - State dialect-specific functions only for the dialect I name.
    - Show assumptions separately from the SQL.
    
    Output:
    1) Restated goal
    2) SQL
    3) Assumptions
    4) NEED FROM SCHEMA
    5) How I should sanity-check the result (using only my columns)
    
    Confirm the rules, then wait.
  3. Paste schema + goal, then review the ASSUMPTIONS list.

    Read the ASSUMPTIONS list and NEED FROM SCHEMA before you run anything. If a join key was assumed, fix the schema paste and regenerate. Never run destructive SQL blind.

    Generate command

    Dialect, schema, and goal are below. Write the SELECT. If you must invent a column, do not—list it under NEED FROM SCHEMA. No destructive SQL unless I later type ALLOW DESTRUCTIVE.
  4. Run it in your own console.

    You still execute. Prefer EXPLAIN or a LIMIT first. If you truly need a mutating statement, use the block below only after a backup you control.

    Destructive-SQL gate

    I typed ALLOW DESTRUCTIVE. Rewrite as the mutating statement I described, with a WARNING (object, filter, irreversibility) above the SQL, and a SELECT that previews matching rows using only my schema. If the filter is missing, refuse.

When not to

  • Never run destructive SQL blind. No DELETE, UPDATE, DROP, TRUNCATE, MERGE, or ALTER until you have read the ASSUMPTIONS list, typed ALLOW DESTRUCTIVE, run a preview SELECT, and have a backup you control.
  • Do not let the model invent a table, column, or join key. Missing schema stays missing; it belongs on NEED FROM SCHEMA.
  • Do not paste production credentials, connection strings, or real PII in the schema dump if you can use aliases.
  • Skip this recipe if you do not have a schema. Describe columns first, or use the CSV recipe instead.

Dated sources

Related recipes

Copied