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.

DbSchema with the AI Assistant side bar open on the right of the shop diagram, showing the Start with suggestions and the question box

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 AI Assistant side bar with the Start with suggestions, the note on what is sent, the toolbar and the question box

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:

ChoiceDbSchema editionWho you pay
Free trialEvery edition, the free Community edition includedNobody: 2 weeks, up to 100 questions, no credit card
DbSchema creditsEvery editionDbSchema, with Purchase Credits
Your own AI providerPro or ArchitectThe AI provider, through your API key
Ollama on your computerPro or ArchitectNobody: 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.

  1. Type your email in the Start your free AI trial dialog.
  2. Press Start Free Trial.
  3. DbSchema emails you a code. Paste it in the dialog, and the trial starts.
The Start your free AI trial dialog: 2 weeks, up to 100 questions, no credit card, with the Email field and the steps Get a code by email and Paste it to start your trial

After the trial, use Purchase Credits to buy more questions.

Ask a question

  1. Type the question in the box at the bottom of the side bar, such as "Write a query to find customers without orders".
  2. 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:

CodeButtons
CREATE TABLE or CREATE INDEXMerge, Editor, Preview
ALTER TABLEMerge, Editor
SELECTRun, Editor
INSERT, UPDATE or DELETEEditor

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 SELECT in 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.

  1. Select the tables on the diagram. Ctrl+click adds a table to the selection.
  2. Right-click one of them and choose Attach to AI.
  3. The Ask AI dialog shows the CREATE TABLE statements of the tables under Attachment. Edit them if you want.
  4. Choose Ask to start from one of the Question Templates, or Attach only to write the question yourself.
  5. Press OK.
The Ask AI dialog with Ask chosen, the question templates Optimize query and Improve performance, and the CREATE TABLE statement of customers as the attachment

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.

  1. Press Settings in the side bar, to open AI Settings.
  2. Choose your provider in AI Provider, such as OpenAI, Claude (Anthropic) or Google Gemini.
  3. Paste your key in Api Key. The provider bills you for the questions.
  4. Choose the Model.
  5. Press OK.
The AI Settings dialog with Claude (Anthropic) chosen in AI Provider, and the fields Api Key, Model, Custom Endpoint URL and Reasoning Effort

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.

  1. Choose Edit → Settings.
  2. Choose AI → AI Assistant in the tree.
  3. Edit the System Message.
  4. Press OK.
The DbSchema Settings dialog on AI → AI Assistant: the Enable AI Assistant check box and the System Message

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.

Next steps