# SQL Console (/docs/guides/sql-console)

Write SQL with schema-aware autocomplete, run full queries or selections, view and chart results, and reopen anything from history.

The SQL Console is a Monaco-based editor with SQL syntax highlighting and
schema-aware autocomplete. Open it from the sidebar.

## Write and run [#write-and-run]

As you type, Dora completes table names, column names (with type hints), SQL
keywords, and aggregate functions from the connected schema, so `users.` offers
the real columns.

- **Run the whole editor** with `Mod+Enter`.
- **Run just the selection** with `Mod+Shift+Enter`. Select one statement in an
  editor that holds several, and only that statement runs.
- **Stop** a long-running query from the toolbar while it executes.
- **Format** the SQL from the toolbar.
- **Comment a line** with `Mod+/`, and **save the script** with `Mod+S`.

Run, explain, format, and save always use the text that is in the editor at that
moment, including the last keystrokes.

## Query tabs [#query-tabs]

Each query tab keeps its own SQL. With a tab focused, the arrow keys, `Home`, and
`End` move between tabs, `Delete` closes the tab, and `F2` renames it.

The divider between the editor and the results can be moved with the mouse, or
with the arrow keys once it has focus.

## Results [#results]

Results open in a table you can sort and filter by column. From there you can:

- **Copy a row** as JSON or SQL from its context menu,
- **Chart** the results, see [Charts](/docs/guides/charts),
- **Export** to CSV, JSON, or SQL, see [Export](/docs/guides/export).

Run an `EXPLAIN` / `EXPLAIN ANALYZE` query and Dora shows the query plan in a
dedicated panel.

## Query history [#query-history]

Press `Mod+Shift+H` to open history. Every query you run is recorded with a timestamp,
a preview, its duration, and whether it succeeded. You can search history, group
it by connection, pin queries you reuse, re-run any entry, and export or clear
history. History rows work from the keyboard: focus one and press `Enter` or
`Space` to load it.

## Ask the AI [#ask-the-ai]

Open the assistant from the console to generate SQL from a description, explain
the current query, or fix an error. See [AI Assistant](/docs/guides/ai-assistant).

<Callout type='info'>
	Prefer your ORM? The console can switch to a Drizzle (`Alt+D`) or Prisma (`Alt+P`) mode, and Dora also has dedicated [Drizzle
	and Prisma runners](/docs/guides/orm-runners).
</Callout>
