Documentation

SQL Editor

SQL Editor

The SQL Editor is VisuaLeaf's dedicated activity for writing, running, and iterating on SQL against your relational databases. It is built on CodeMirror 6, so you get fast syntax highlighting, dialect-aware autocomplete, multi-tab editing, and a rich result viewer that can switch between grid, tree, JSON, and explain-plan output on the same query.

Quick Start

  1. Open a connection to a SQL database (Postgres, MySQL, MariaDB, SQL Server, or SQLite).
  2. Click SQL Editor in the activity bar (or press Ctrl/Cmd + Shift + S).
  3. Type a query. Autocomplete offers table and column names as you type.
  4. Press F5 to run the whole buffer, highlight a fragment and press F9 to run just the selection, or press Ctrl/Cmd + F5 to run up to the cursor.
  5. Inspect results in the grid, or flip to the tree, JSON, or explain-plan view.

Opening the Editor

Each connection has its own SQL Editor context so tabs, history, and result sets stay scoped to the database you are working on:

  • From the sidebar, right-click any database and choose Open SQL Editor.
  • From the activity bar, click the SQL icon; the editor opens on the last-used tab.
  • From any table row, choose Query in SQL Editor to prefill a SELECT against that table.

Writing Queries

The editor understands the SQL dialect of the current connection and adjusts keywords, functions, and quoting rules accordingly.

Autocomplete

Trigger the completion menu with Ctrl + Space, or just keep typing:

  • Table names after FROM, JOIN, UPDATE, INTO.
  • Column names after a table alias and a dot (e.g. u. lists columns of the aliased table).
  • Built-in functions such as COUNT, NOW(), COALESCE, JSON_EXTRACT.
  • Snippets for common shapes: selectall, joinon, groupbycount, upsert.

Example

SELECT id, name, email
FROM users
WHERE active = true
ORDER BY created_at DESC
LIMIT 100;

Executing Queries

The editor exposes several execution modes so you can iterate on part of a script without re-running everything:

Action Windows / Linux macOS
Run entire buffer F5 F5
Run current selection F9 F9
Run up to cursor Ctrl + F5 Cmd + F5

Multiple Statements

If your buffer contains several statements separated by ;, running the whole buffer produces one result tab per statement. The status bar shows the aggregate row count and total elapsed time.

Result Viewer

Every executed query produces a result tab that can render in four modes:

Grid

Sortable, resizable columns with type-aware cell rendering (dates, JSON, NULL, booleans). Right-click a cell to copy, filter by value, or open a related row via a foreign key.

Tree

Expandable tree of rows and nested values. Great for wide result sets with lots of columns, or when a cell contains JSON you want to drill into without leaving the result panel.

JSON

Each row rendered as a JSON object. Handy for LLM prompts, API mocking, or piping to jq.

Explain

Runs the current statement through the dialect's EXPLAIN and renders the plan for inspection alongside the result.

Multiple Result Sets

When a stored procedure or a batch returns more than one result set, each appears as its own sub-tab under the result panel. Metadata rows (row count, elapsed) are shown per set.

Saving to Query Library

Press Ctrl/Cmd + S to save the current buffer. Saved queries include:

  • A name, description, and tags for search.
  • The dialect and originating connection, so parameters resolve correctly on reload.
  • Optional bound parameters (e.g. :tenant_id) prompted at run time.

Access saved queries from the Saved Queries sidebar entry or by typing @ anywhere in the editor.

Keyboard Shortcuts

Shortcut Action
Ctrl/Cmd + TNew editor tab
Ctrl/Cmd + WClose current tab
Ctrl/Cmd + SSave query to library
Ctrl/Cmd + /Toggle line comment
Ctrl/Cmd + SpaceTrigger autocomplete
Ctrl/Cmd + Shift + FFormat SQL
F5Run entire buffer
F9Run current selection
Ctrl/Cmd + F5Run up to the cursor

Pro Tips

  1. Use aliases early: Alias tables in the FROM clause first — autocomplete uses the alias immediately for the rest of the query.
  2. Highlight to explore: Wrap a fragment in a SELECT, highlight it, and hit F9 to preview intermediate results without touching the full query.
  3. Bind sensitive values: Use :parameter placeholders instead of hardcoding IDs — VisuaLeaf will prompt at run time and never store the value in the saved query.

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial