AI Assistant
The AI Assistant is a side bar in DbSchema where you ask an AI model about your database. It can review your design, write SQL, and create tables that you can add to your diagram. It reads the design of your open project automatically, so you can ask about your tables by name.
The design is your DbSchema project: the tables, columns and diagrams that you see in DbSchema. The assistant can also use a real database, if you allow it on that database's connection. To see what leaves your computer, read What DbSchema sends to the AI.
Open the AI Assistant
Click the vertical AI Assistant tab at the right edge of the DbSchema window.
The side bar suggests first questions under Start with, such as "Review my schema for normalization issues". Above the question box is the toolbar:
- Attach, the paper clip, attaches tables to the question.
- The model name shows the AI model that answers. Click it to change the model.
- Conversation, the clock, starts a new conversation or opens an earlier one.
- Settings, the wrench, opens the AI settings.
- Send, the arrow, sends the question. Ctrl+Enter sends it too.
Choose how the AI is paid
The assistant needs an AI provider: a company that runs AI models, such as OpenAI or Anthropic. You have three choices:
| Choice | DbSchema edition | Who you pay |
|---|---|---|
| Free trial | Every edition, the free Community edition included | Nobody: 2 weeks, up to 100 questions, no credit card |
| DbSchema credits | Every edition | DbSchema, with Purchase Credits |
| Your own AI provider | Pro or Architect | The AI provider, through your API key |
| Ollama on your computer | Pro or Architect | Nobody: the model runs on your computer |
When you first open the assistant without an AI subscription, DbSchema shows Start your free AI trial.
Start the free trial
With the trial, DbSchema uses its own AI subscription to answer your questions.
- Type your email in the Start your free AI trial dialog.
- Press Start Free Trial.
- DbSchema emails you a code. Paste it in the dialog, and the trial starts.
After the trial, use Purchase Credits to buy more questions.
Ask a question
- Type the question in the box at the bottom of the side bar, such as "Write a query to find customers without orders".
- Press Send, or Ctrl+Enter.
The answer appears in the side bar.
How the assistant finds the answer
The assistant looks up what it needs in your design, such as the columns of customers and orders.
Each lookup is a tool call: a request from the assistant to DbSchema.
The answer lists the tool calls, with what each one asked for and what it returned.
If the AI model reasons before it answers, the answer starts with a collapsed Thinking block.
Some tool calls need your permission, such as reading the rows of a table. DbSchema then opens a dialog, and the assistant waits for your answer. AI Permissions describes that dialog.
Use the answer
SQL in an answer comes in code blocks, with buttons under each block. The buttons depend on what the code does:
| Code | Buttons |
|---|---|
CREATE TABLE or CREATE INDEX | Merge, Editor, Preview |
ALTER TABLE | Merge, Editor |
SELECT | Run, Editor |
INSERT, UPDATE or DELETE | Editor |
Every code block also has a Copy button.
- Merge adds the statement to your design.
- Preview shows the new tables on a preview diagram, before you merge them.
- Run runs the
SELECTin the database and shows the result. - Editor opens the code in an SQL Editor, where you can change it before you run it.
- Copy copies the code.
Merge changes your design, not the database. To apply the change to the database, use Schema Synchronization.
Attach tables to a question
You can send the structure of chosen tables with your question. Then you can edit the table information before you send it, and the assistant does not need to look these tables up.
- Select the tables on the diagram. Ctrl+click adds a table to the selection.
- Right-click one of them and choose Attach to AI.
- The Ask AI dialog shows the
CREATE TABLEstatements of the tables under Attachment. Edit them if you want. - Choose Ask to start from one of the Question Templates, or Attach only to write the question yourself.
- Press OK.
Your edits change only what is sent to the AI, not your design. The line above the question box now says what is attached, such as "1 table attached, sent with your next question".
Keep or start conversations
When it answers a new question, the assistant can use the earlier questions and answers of the same conversation. To start over, press Conversation and choose New Conversation.
DbSchema saves your conversations. To open an earlier one, rename it or delete it, press Conversation and choose Manage.
Use your own AI provider
If you have an API key from an AI provider, such as OpenAI or Anthropic, DbSchema can use it. An API key is a secret code from the provider's developer website. A chat subscription, such as ChatGPT Plus, does not include one. This needs a DbSchema Pro or Architect license.
- Press Settings in the side bar, to open AI Settings.
- Choose your provider in AI Provider, such as OpenAI, Claude (Anthropic) or Google Gemini.
- Paste your key in Api Key. The provider bills you for the questions.
- Choose the Model.
- Press OK.
The AI Provider list holds OpenAI, Azure OpenAI, Claude (Anthropic), Google Gemini, DeepSeek, Grok (xAI), Mistral and Venice AI. Ollama is a program that runs AI models on your own computer. It needs no key, and your questions never leave your computer. To use the trial or the credits again, choose DbSchema AI at the top of the list.
Reasoning Effort controls how much the model reasons before it answers. Leave it off to let the model decide.
What DbSchema sends to the AI
What goes to your AI provider
- your question, and the earlier questions and answers of the conversation;
- the tables that you attach;
- what the assistant reads from your design, such as names, data types, comments and scripts;
- the system message, the instructions that go with every question.
The assistant reads only what it needs for each question. DbSchema does not send your database passwords. With Ollama, nothing leaves your computer.
What the assistant may do in a database
The assistant uses a database only through a connection where you ticked Allow AI tools to access this database connection. By default, DbSchema asks you before the assistant reads the rows of a table. DbSchema always asks before the assistant changes a database. What the assistant reads from the database is sent to your AI provider too.
AI Permissions explains these settings.
Customize the system message
The system message contains the instructions that go with every question, such as which SQL dialect to use: the variant of SQL that your database understands. Add your own rules there, such as how to name tables.
- Choose Edit → Settings.
- Choose AI → AI Assistant in the tree.
- Edit the System Message.
- Press OK.
In the system message, $dbms stands for the database type of the design, such as PostgreSQL.
Turn the assistant off
On the same AI → AI Assistant page, untick Enable AI Assistant and press OK. The AI Assistant tab disappears after you restart DbSchema.
Common problems
The AI Assistant tab is missing
The assistant is turned off. Tick Enable AI Assistant in Edit → Settings → AI → AI Assistant, and restart DbSchema.
"This feature requires a DbSchema license key" when I choose my own provider
To use your own provider or Ollama, you need a DbSchema Pro or Architect license. Choose DbSchema AI in AI Provider to use the trial or the credits, which work in every edition.
The assistant does not know my tables
The project's AI tool preset may be No model access, which stops the AI from reading the design. Choose File → Properties and set AI Tool Preset to Read only or Edit access. AI Permissions explains the presets.
"The question reached the limit of tool calls"
The assistant reached the maximum number of tool calls for one question. Ask again to let it continue.