Query


Query Editor is where you write SQL. A single file can hold many statements, separated by ; or a newline; they run one by one, and each statement gets its own result tab below.

▶ Tutorial

Multiple statements → run selection / Run All → one result tab each → Output records timings and errors

Editor layout

AreaNotes
File tabsThe current SQL file (for example Query Editor 1.sql); several can be open at once
ToolbarRun and its dropdown, plus open, format, AI, and settings buttons
EditorSyntax highlighting, line numbers, current-line highlight; separate statements with ; or newlines
Top rightSchema selector, Ln, Col position, Spaces indentation, UTF-8 encoding
Result areaOutput log and RESULT-1, RESULT-2, … tabs

Statements

  • Separate statements with ; or with a plain newline; the two styles can be mixed.
  • A line starting with -- is a comment and does not run.
  • With a selection, Run Current runs only the selected text; without one, it runs the statement under the cursor.
  • Statements run in the order they appear, and results and log entries follow the same order.

Run menu

Click the dropdown next to Run:

CommandWhat it does
Run CurrentRun the current statement, or the current selection
Run AllRun every statement in the file (split on ; or newlines), sending and returning them one at a time
Run as ScriptSend the whole file as one request; all statements run inside one transaction
AI Assistant ▸Hand the SQL to AI Chat to explain, fix, or optimize
ReloadReload the file from disk
Beautify SqlFormat SQL with consistent casing and indentation
Return on ErrorStop at the first error instead of continuing
Find / ReplaceFind and replace inside the editor
Cut / Copy / PasteStandard editing commands
Refactor ▸Rename tables or aliases and update every reference
Fold / Select AllFold code or select everything

Choosing a run mode

SituationUse
Debugging a single statementRun Current (select it first if needed)
Running all queries in a file onceRun All
Scripts that must run in sequence, such as DDL plus bulk insertsRun as Script

The key difference between Run All and Run as Script is transactions:

Run AllRun as Script
SendingOne statement per requestWhole file in one request
TransactionsEach statement commits on its ownAll statements share one transaction
SpeedOne round trip per statementA single round trip, noticeably faster for bulk writes
Failure midwayLater statements still run (unless Return on Error is on)The whole block is one transaction; earlier writes do not take effect on their own

Schema context

The top right of the editor shows the current database and schema (for example open_demo.public). Clicking it opens a searchable schema list:

  • The search box filters by name; Reset on the right clears it.
  • display buildin schemas controls whether system schemas such as information_schema are listed.
  • After choosing one, unqualified table names resolve against that schema.

Switching schema only affects later runs; it never rewrites SQL you already wrote.

Output

Every run leaves a record in Output, roughly like this:

open_demo.public> select * from customer c where c.email is not null
Fetched Rows 20777, in 79ms (execution: 50ms, fetching: 17ms)
  • The first line is the statement that actually ran, prefixed with database.schema.
  • Fetched Rows is the row count; the parentheses break out execution time and fetch time.
  • Errors are shown in red, for example relation "address" does not exist.
  • With multiple statements, every entry is listed in order so you can check each one.
  • Output belongs to the current tab only; full history across sessions lives in Query History.

Results

  • Each statement that returns rows gets a RESULT-n tab, in execution order.
  • Result tabs support filtering, sorting, copying, and exporting; the status bar shows Read Only.
  • Only row-returning statements such as select get a result tab; insert, update, and delete only record affected rows in Output.

Hover info

Hold Cmd on macOS or Ctrl on Windows / Linux and move the pointer over a table, column, or function to show an info card. Clicking while holding jumps to that object.

Hover info card

Holding Cmd over public.customer: the card shows the object type and its DDL

How to use

  1. Hold Cmd / Ctrl.
  2. Move the pointer over a table, column, or function name in the SQL.
  3. The word is underlined, the cursor becomes a hand, and the card appears.
  4. Click while still holding to jump to the object.

Release the key, scroll, click the editor, or move focus away to leave this mode.

Supported objects

TypeInfo cardOn click
Table / view / materialized viewObject detailsOpens the table’s Content view
ColumnColumn type, comment, and so onOpens the table’s Structure and locates the column
FunctionFunction details—

schema, database, and aliases do not trigger the card.

Interaction notes

  • The hold key is SmartHit and can be changed in Keymap; it defaults to Cmd on macOS and Ctrl elsewhere.
  • Hover mode activates after about 50ms to avoid accidental triggers.
  • Jumps use the database / schema on the token, falling back to the current connection when missing.

Script example

A table, an insert, and a query, written as one script and run with Run as Script:

CREATE TABLE demo_task (
    id    SERIAL PRIMARY KEY,
    title TEXT NOT NULL,
    done  BOOLEAN DEFAULT false
);

INSERT INTO demo_task (title) VALUES ('first'), ('second');

SELECT * FROM demo_task;

Steps:

  1. Write the whole script in the editor.
  2. Open the dropdown next to Run and choose Run as Script (or press Run to execute everything).
  3. Follow each entry in Output; the SELECT result appears in the RESULT-1 tab.

Notes:

  • For DDL, inserts, and updates, double-check the statements and the target database before running.
  • To stop at the first error, enable Return on Error first; behavior is described above.
  • Result tabs stay read-only; write operations only show up in the data and in Output.

Multi-statement results

When several statements run together, each one reports success or failure on its own:

  • A marker appears left of the line numbers: a green check for success, a red cross for failure.
  • Output records them in order; write statements show Affected Rows: N, in Xms.
  • Failures are shown in red, for example duplicate key value violates unique constraint "PK_ContactType_ContactTypeID".
  • A failing line offers Fix on the right, which hands the statement to AI for repair.
  • Only statements that return a result set (SELECT) create a RESULT-n tab; INSERT / UPDATE / DELETE only appear in Output with affected rows.

Multi-statement results

The first two inserts succeed (checks), the third fails on a duplicate key (red cross); Output lists affected rows and the error

By default, a failure does not stop the remaining statements. Enable Return on Error when you want it to.

Return on Error

Off by default: after one statement fails, the rest still run. When enabled, the run stops at the first error — useful for ordered scripts such as create table → insert → verify.

Editor commands

  • Beautify Sql: consistent casing and indentation, easier to read long scripts.
  • Find / Replace: search within the current file, ⌘F / Ctrl+F.
  • Refactor: rename tables or aliases and update references in the file; default key F2 (see Keymap).
  • AI Assistant: send the selected SQL to AI to explain, fix, or optimize; see AI Chat.

AutoComplete

Typing a table, column, or SQL keyword opens the completion list automatically, ordered by the context of the current statement.

What gets suggested

TypeNotes
KeywordsSELECT, FROM, WHERE, and so on, in either case
Tables / viewsTables, views, and materialized views in the current schema
ColumnsColumns of the tables used by the current statement
AliasesAliases already defined; also suggested when you pick a table name
Database / schemaCross-database and cross-schema references
Functions / proceduresBuilt-ins plus functions and procedures in the current database
Data typesTypes used when creating tables or altering columns

Context behavior

  • After FROM, tables and views come first; after WHERE or ON, columns come first.
  • Picking a table name suggests an alias based on its initials when none exists yet (for example customer_order → co).
  • Aliases already used in the statement are not suggested again.

Doc hints

When columns and tables carry comments, the completion list shows those comments on the right (controlled by Enable Doclet), so you do not have to check Structure for field meanings.

Alias suggestions

After inserting a table name, with Enable Auto Alias on, the editor shows a grey alias suggestion after the cursor. Aliases are not arbitrary; the rules are:

  1. Only tables and views get one; columns and functions do not.
  2. Split the table name on _, take the first letter of each part, and lowercase it: customer_order → co, address → a.
  3. If the result starts with a digit, prefix it with t.
  4. Deduplicate against aliases already in the statement, in this order:
CaseSuggested value
co is freeco
co is taken and is two lettersFall back to the first letter, c
c is also takenco2
co2 is also takenFind the highest numeric suffix on co and add one (for example co3)

Only two-letter aliases fall back to one letter; three-letter or longer aliases (such as coi) simply gain a numeric suffix when taken.

Accepting and dismissing:

  • Tab accepts the suggestion and writes the alias into the statement.
  • Esc dismisses it.
  • Moving the cursor away hides it.

Example: in one statement, FROM customer_order suggests co; then JOIN customer_order_item suggests coi, unless coi is taken, in which case it falls back to co or coi2.

Settings

Completion is configured under Preferences → Settings → AutoComplete:

  • Keywords Case: automatically upper- or lowercase keywords, or follow the database.
  • Enable Add Space: insert a space after keywords (always after FROM).
  • Enable Auto Alias: suggest aliases after table names.
  • Enable Doclet: show column comments in the list.
  • Disable Auto Complete: turn completion off entirely.

Defaults for every option are listed in Settings.

Status bar

The bottom of the editor shows the row count and two timings for the current statement, for example Rows 20,777 in table 73ms (96ms):

PositionMeaning
73ms before the parenthesesQuery Time: from sending the request to receiving the result column metadata
96ms inside the parenthesesduration Time: the full load, including fetching and rendering, usually larger than the first

Hovering the timings shows the full tooltip: Query Time: … , duration Time: …. With no rows returned, the bar reads No Rows in table.

When results are read-only, Read Only appears on the right.

Shortcuts

Default keys for Run Current, Run All, and the rest are in Keymap.