> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tamery.app/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL editor

> Write and run SQL in Tamery's Monaco-based editor, with query zones, saved queries, inline AI, and a query log.

The SQL editor is built on Monaco (the VS Code editor), so syntax highlighting, autocomplete, multi-cursor, and shortcuts like <kbd>Ctrl</kbd>+<kbd>Z</kbd> and <kbd>Ctrl</kbd>+<kbd>/</kbd> work as expected.

## Writing queries

Autocomplete suggests tables, columns, keywords, and functions from your live schema, for PostgreSQL, MySQL, MSSQL, and ClickHouse.

**Query zones** let you keep several queries in one file, separated by `---` delimiter lines. Each zone runs independently.

* Click inside a zone to focus it.
* **Run** (or <kbd>Ctrl</kbd>+<kbd>Enter</kbd>) executes the focused zone.
* Add a `---` line to create a new zone.

## Running queries

Place the cursor in a zone and **Run** (or <kbd>Ctrl</kbd>+<kbd>Enter</kbd>). Results appear below the editor with sorting, column resizing, and copy.

On error, the database message shows inline. Use **Fix with AI** to get a corrected query.

## Saving queries

Click **Save**, name the query, and it's stored per connection. Open saved queries from the **Saved queries** panel, where you can rename, duplicate, or delete them.

## AI in the editor

<CardGroup cols={2}>
  <Card title="Generate / modify SQL" icon="wand-magic-sparkles" href="/features/ai-assistant">
    Press <kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>K</kbd> in a zone and describe what you want. A diff
    shows the change before you apply it. Subscription feature.
  </Card>

  <Card title="Fix on error" icon="circle-exclamation" href="/features/ai-assistant">
    **Fix with AI** appears next to an error and suggests a correction you apply in one click.
    Subscription feature.
  </Card>
</CardGroup>

The AI has full schema context, so it uses your real table and column names. See the [AI assistant](/features/ai-assistant).

## Query logger

Every executed query is recorded in the **Query logger** panel: SQL text, timestamp, status, and row count. Click an entry to copy the SQL back into the editor. The log is per session and clears when you close the connection.
