Editor Basics
Write and run SQL in query tabs, with highlighting, autocomplete, editing commands and safe execution.
Every connection window has a SQL editor. Open as many query tabs as you need, write SQL with autocomplete, and run one statement or the whole script.
Query tabs
Open a new query tab with File ▸ New Query Tab (⌘T) or the SQL button in the top bar.
Query tabs are named Query 1, Query 2 and so on, or after the SQL file or favorite they came from. A • in the tab marks unsaved changes to a file.
Toolbar
| Button | Description |
|---|---|
| Run Current (▶) | Run the selection or the statement under the cursor. |
| Run All | Run the whole script. |
| Stop | Cancel the running query on the server. |
| ★ Save | Save the query as a favorite (⌘D). |
| Format | Format the SQL. |
The right side of the toolbar shows a reminder of the main shortcuts and the current row limit, for example ⌘↩ run current · ⇧⌘↩ run all · ⌥⌘F format · limit 1,000 rows. It reflects your own shortcuts if you change them.
The gutter shows line numbers, and the statement that ⌘↩ would run is highlighted with a faint background.
Syntax highlighting
The editor highlights SQL using the keywords of the connection's dialect:
- Keywords in green.
- Strings in amber.
- Comments dimmed.
- Numbers in a softer tone.
Font ligatures are turned off, so operators like <= and != look exactly as typed.
Autocomplete
Suggestions appear after you type two characters, or right after a qualifier and a dot such as o.. They include:
- SQL keywords.
- Tables.
- Columns of the tables used in the current statement.
Aliases are understood. After FROM orders o, typing o. lists the columns of orders. This also works with AS, JOIN and comma-separated table lists.
Aliases of subqueries and CTEs aren't resolved yet.
Editing commands
| Command | Shortcut |
|---|---|
| Query ▸ Toggle Comment | ⌘/ |
| Query ▸ Shift Right | ⌘] |
| Query ▸ Shift Left | ⌘[ |
| Indent / outdent the selection | Tab / ⇧Tab |
Pressing Return keeps the current indentation and indents after (.
Auto-closing pairs
Brackets and quotes close automatically:
- Typing an opening bracket or quote inserts the closing one.
- With text selected, typing a bracket or quote wraps the selection.
- Typing the closing character steps over it.
Backspaceon an empty pair removes both.
Pairs aren't auto-closed inside strings or comments, or right after a word.
The editor doesn't support multiple cursors.
Find and replace
The editor uses the standard macOS find bar:
| Command | Shortcut |
|---|---|
| Edit ▸ Find ▸ Find… | ⌘F |
| Find and Replace… | ⇧⌘F |
| Find Next | ⌘G |
| Find Previous | ⇧⌘G |
| Use Selection for Find | ⌘E |
Running queries
Run current or all
- Query ▸ Run Current Statement (
⌘↩) runs the selection, or the statement under the cursor when nothing is selected. - Query ▸ Run All (
⇧⌘↩) runs the whole script.
Each statement gets its own result. See Query Results.
If the SQL contains placeholders such as :name or $1, Mantidb asks for their values first. See Query Parameters.
Safe mode
Every write goes through the connection's safe mode. Statements run one by one and stop at the first error.
Stopping a query
Click Stop to cancel the running query on the server. Each engine uses its own method:
| Engine | How it stops |
|---|---|
| PostgreSQL | pg_cancel_backend from a second session |
| CockroachDB | CANCEL QUERIES |
| MySQL / MariaDB | KILL QUERY |
| SQL Server | An attention signal |
| SQLite | sqlite3_interrupt |
On Neon and Supabase transaction poolers (Neon
-poolerhosts, Supabase port6543), Stop has no effect.
SQL Server batches
On SQL Server, a line containing only GO separates batches, as in SQL Server Management Studio.
MySQL scripts
On MySQL / MariaDB, scripts are split into statements by ; on your Mac before they are sent.
Calling a stored procedure that returns result sets with
CALLfails.#comments and\'inside strings can also confuse the splitter.
History
Every query you run is saved to the connection's history, with its date and duration. Find it in the History tab of the sidebar or with ⌘K. See Favorites & History.
