SQL and schema help from pasted text
Analyse a database with AI: paste the schema, get SQL you can check
ZeroTwo reads the schema, sample rows, query text or exported results you paste into a chat. It writes and explains SQL, flags join and NULL risks, and suggests tuning ideas.
The boundary: text in, text out. This workflow does not connect to your database, so you run every query and verify every result.
Free plan: 100 free credits to start, no card required.
Illustrative chat
You
Schema below (PostgreSQL 16). Which customers drove the most order value in the last 90 days?
orders(id, customer_id, total,
status, created_at)
customers(id, name, email)ZeroTwo
- A SELECT with the join and the 90-day filter
- The assumptions it made, to confirm
- Checks to run before you trust the totals
What you hand over, what comes back, what stays with you
Most disappointment with AI database help comes from expecting it to see your data. It does not. It reasons over what you paste, so the quality of the answer tracks the quality of the context.
You hand over
- CREATE TABLE statements or a schema export, plus the dialect and version (for example PostgreSQL 16).
- A few sample rows, with personal data masked first.
- The query you already have, if you want it explained or tuned.
- For tuning: the EXPLAIN output, the index list and rough row counts.
- Exported query results (pasted or as a file) if you want them interpreted.
Comes back
- SQL for the question you described, written for the dialect you named.
- A plain-language walk-through of the joins and filters it chose.
- The assumptions it had to make, such as what counts as a customer or a cancelled order.
- Candidate rewrites and index ideas, with the reason for each.
- A first read of trends and oddities in results you exported.
Stays with you
- Running the query, ideally on a replica or a dev copy.
- Checking the output against a number you already trust.
- Credentials: never paste passwords or connection strings.
- Deciding whether an index is worth its cost on writes.
- Anything that changes data: DDL, UPDATE, DELETE, migrations.
One question, start to finish
An illustrative example in PostgreSQL. The tables, the query and the rows were written by hand to show the shape of the workflow. They are not a recorded ZeroTwo output and the figures are invented.
1. You paste
-- PostgreSQL 16
CREATE TABLE customers (
id bigint PRIMARY KEY,
name text NOT NULL,
email text
);
CREATE TABLE orders (
id bigint PRIMARY KEY,
customer_id bigint REFERENCES customers (id),
total numeric(12,2),
status text,
created_at timestamptz NOT NULL
);
-- Question: top 10 customers by total order
-- value over the last 90 days.2. The SQL you might get back
SELECT c.id,
c.name,
COUNT(*) AS orders,
SUM(o.total) AS total_order_value
FROM customers AS c
JOIN orders AS o ON o.customer_id = c.id
WHERE o.created_at >= now() - interval '90 days'
AND o.status <> 'cancelled'
GROUP BY c.id, c.name
ORDER BY total_order_value DESC
LIMIT 10;3. The result you should expect to see
| id | name | orders | total_order_value |
|---|---|---|---|
| 1042 | Customer 1042 | 14 | 18,420.50 |
| 877 | Customer 877 | 9 | 16,275.00 |
| 2310 | Customer 2310 | 11 | 15,990.25 |
Sample rows, invented for illustration, followed by seven more in a real result. Ten rows because of LIMIT 10.
4. Assumptions to confirm
- Is a cancelled order excluded, and are refunds a separate status?
- Is total before or after tax and shipping?
- Does the last 90 days mean a rolling window from now, or whole calendar days?
- Customers with no orders are dropped by the inner JOIN. Is that what you want?
Once you have real rows, export them and turn exported query results into checked analysis.
Check the query before you trust it
A query that runs is not a query that is right. These six checks catch the mistakes generated SQL, and hand-written SQL, tend to hide.
Run it read-only first
Use a replica or a dev copy, or open a read-only transaction (START TRANSACTION READ ONLY in PostgreSQL and MySQL). A query that only reads cannot change your data while you are still learning what it does.
Count before you aggregate
Run the same JOIN and WHERE without GROUP BY and compare the row count with what you expect. A join that fans out (one order matching several rows) inflates every SUM without raising an error.
SELECT COUNT(*) AS rows_before_group FROM orders o JOIN customers c ON c.id = o.customer_id WHERE o.created_at >= now() - interval '90 days';Check NULLs and join type
SUM skips NULL totals, and an inner JOIN drops orders whose customer_id is NULL. Count the gaps so you know what the result silently leaves out.
SELECT COUNT(*) - COUNT(total) AS null_totals, COUNT(*) - COUNT(customer_id) AS orphan_orders FROM orders;Reconcile one figure
Pick a customer or a period whose total you already know from a finance report or a dashboard and make sure the query reproduces it.
Test the date edges
Run it for a window that ends on a known day and look at the first and last rows. timestamptz versus timestamp and the session time zone are the usual causes of an off-by-one-day total.
Read the plan before a big table
Plain EXPLAIN shows the plan without running the statement. EXPLAIN ANALYZE actually executes it, so never use it on an UPDATE or DELETE you have not read.
Tuning a slow query: paste the plan, not just the row count
A row count cannot tell a model whether the cost is a missing index, a bad join order, or a filter that matches most of the table. The execution plan can. Give it the evidence and ask it to point at the plan line it is reacting to.
Thin prompt
This query takes 45 seconds to run. How can I optimise it? [query]. My orders table has 10 million rows.
No dialect, no plan, no indexes, no sense of how selective the filter is. Any answer is a guess.
Prompt with evidence
- PostgreSQL 16. Here is the query: [query].
- Here is EXPLAIN (ANALYZE, BUFFERS) for it: [plan].
- Existing indexes on orders and customers: [output of \d orders].
- Row counts: orders ~10M, customers ~200k. About 2% of orders fall in the last 90 days.
- Which node in the plan is the main cost, and what would you change? Quote the plan line you are reacting to.
If the reply proposes an index without naming a sequential scan or a costly node in your plan, ask which line it is responding to. Then test the index on a copy.
Name your engine: plan commands and dialect traps
Tell the model the engine and version, then paste the plan in that engine's format. The right column lists places where SQL written for one engine commonly breaks on another.
| Engine | Plan to paste | Dialect traps to review |
|---|---|---|
| PostgreSQL | EXPLAIN (ANALYZE, BUFFERS) | timestamptz versus timestamp, ILIKE, DISTINCT ON, jsonb operators, quoted identifiers. |
| MySQL | EXPLAIN ANALYZE (MySQL 8.0.18 and later) | Backtick identifiers, ONLY_FULL_GROUP_BY mode, collation affecting comparisons and joins. |
| SQLite | EXPLAIN QUERY PLAN | Dynamic typing, limited ALTER TABLE, date handling through strftime. |
| SQL Server | Actual execution plan, SET STATISTICS IO ON | T-SQL: TOP instead of LIMIT, ISNULL versus COALESCE, string concatenation rules. |
| Oracle | EXPLAIN PLAN FOR, then DBMS_XPLAN.DISPLAY | FETCH FIRST or ROWNUM instead of LIMIT, empty string is treated as NULL, PL/SQL blocks. |
| BigQuery | Dry run and the job details page (bytes processed) | Cost follows bytes scanned: select only the columns you need and filter on the partition column. |
| Snowflake | Query Profile | VARIANT path syntax and FLATTEN for semi-structured data, unquoted identifiers fold to upper case. |
| MongoDB | explain("executionStats") | Not SQL: aggregation pipelines, and the schema is per collection, so paste sample documents. |
Swipe the table sideways for every column. General engine notes, not a ZeroTwo support matrix. Confirm syntax against your engine's documentation and version.
Run the same prompt on two models and diff the SQL
We do not publish a ranking of models for SQL. How well a model handles your schema is something you can test in a few minutes: send identical context to two of them, then compare the queries and the assumptions each one states.
GPT-5
OpenAI
Claude Sonnet 4.5
Anthropic
Gemini 3 Pro
Google
Grok 4
xAI
Model access depends on your plan. Browse the current model list before choosing a pair.
What the plans cover for database work
Paid plans run on a monthly credit allowance and a pool of Auto requests, so heavy schema work is metered, not unlimited. The pricing page has every current number.
Free
$0/mo
- 100 free credits to start
- +20 bonus credits every day you log in
- Limited model selection
- No card required
Pro
$29.99/mo
- 3,500 monthly credits
- 2,500 free Auto requests / month
- Better unlimited chat model selection
- $26.99/mo when billed annually
Questions before you paste a schema
How can AI analyse a database it cannot see?
It works from text you provide: a schema, sample rows, a query, an EXPLAIN plan or exported results. From that it can write and explain SQL, point out joins and NULL risks, and suggest optimisations. It never touches your data, so every query is run, and checked, by you.
Does ZeroTwo connect straight to my database?
This page describes the paste-in workflow and nothing on it depends on a live connection. Connectors are a separate feature, and the connectors page lists what is supported.
Is it safe to paste my schema?
Table and column names can reveal business details, so mask them and any personal data if your policy requires it. Never paste credentials or connection strings. Read the ZeroTwo privacy policy for how data is handled; this page makes no compliance claims.
Can it write INSERT, UPDATE, DELETE or migrations?
It can draft them, but treat anything that changes data as a review item: read the statement yourself, run it inside a transaction on a copy first and keep a rollback ready.
How do I know the SQL is correct?
You verify it. Run it read-only, compare row counts before aggregation, count NULLs and orphaned rows, reconcile one total you already trust and test the date boundaries. The checklist above covers each step.
What does it cost?
The Free plan gives 100 free credits to start and 20 bonus credits every day you log in, with limited model selection and needs no card. Pro is $29.99/month ($26.99/month billed annually) with a monthly credit allowance and Auto requests. Allowances, not unlimited use, set how much analysis you can run; the pricing page has the current numbers.
Data handling details live in the privacy policy.
Explore more
- AI agent for data analysis
Turn exported results and files into a checked analysis.
- AI code generator
General code generation beyond SQL.
- Best AI for coding
How to pick a model for programming work.
- Connectors
What ZeroTwo can connect to, separate from this paste-in workflow.
- Pricing
Plans, credits and Auto-request allowances.