dbDBCraftDocs
Documentation/Development modules
Chapter 16

SQL Editor

The default module, and the one you will use most.

#16.1Tabs

The tab strip runs across the top of the editor.

ActionHow
New tab+ at the right of the strip, the 📄+ toolbar button, or the command palette. New tabs are named Query 1, Query 2, … reusing the lowest free number.
Rename a tabDouble-click the tab name, type, press Enter (or Esc to cancel).
Close a tabThe × on the tab. The last remaining tab cannot be closed.
Pop outThe button at the far right of the strip.

An amber dot on a tab means unsaved changes.

Tabs survive restarts. Every tab’s title and contents are saved locally as you type, along with which tab was active. Closing and reopening the application brings your work back exactly as it was.

Besides ordinary SQL tabs, the editor also hosts three special tab types, all created from the Object Browser:

  • Object tabs — a read-only viewer with Columns / Data / DDL sub-tabs (§19.5).
  • Program tabs ("(Edit)") — an object’s source loaded for editing and recompiling.
  • Diff tabs ("Diff: A vs B") — a side-by-side read-only comparison of two objects’ DDL.

#16.2Writing SQL

The editor is a full code editor with:

  • Syntax highlighting for SQL and PL/SQL.
  • A minimap down the right edge.
  • Word wrap, line numbers, and bracket matching.
  • Error markers. When a statement fails with a line number, that line is underlined in red and hovering it shows the compilation error.
  • Colourblind-safe themes. If you select a colour-vision mode in Settings → Accessibility, the editor’s syntax palette switches to a matched scheme (red-green safe, tritan safe, or monochrome with bold keywords) in both light and dark.
  • Adjustable font size, set in Settings → Appearance → Editor font size (10–24 px).

Autocomplete triggers on space and on .:

  • After a dot (HR.) it lists the tables and views in that schema.
  • Otherwise it offers SQL keywords plus the tables in your default schema.

Object lists are cached after the first fetch, so completion stays responsive.

#16.3Executing statements

MethodEffect
F5Execute.
Ctrl+EnterExecute.
▶ toolbar buttonExecute.
Command palette → Execute statementExecute.

What gets executed:

  • If you have selected text, only the selection runs. This is the fastest way to run one statement out of a long script.
  • Otherwise the entire tab contents run. The server splits the text into statements and executes them in order, handling PL/SQL blocks correctly.

Multiple result sets. A script that contains several SELECTs produces several grids — the results panel shows one tab per result set (Result 1, Result 2, …) plus a Script Output tab summarising statements that produced no grid.

While a query runs the toolbar collapses to a single Stop button, the status bar shows a pulsing Executing, and the tab bar stays usable.

#16.4Explain plan

Press the ☰ toolbar button or use the palette’s Show Explain Plan. The plan is returned as a text plan table and displayed in the results grid. A trailing semicolon is stripped automatically for plain SQL (but preserved for PL/SQL, where it is part of the syntax).

#16.5Formatting

Shift+Alt+F, or the ¶ toolbar button, reformats the entire tab using PL/SQL formatting rules — consistent keyword casing, indentation and line breaks.

#16.6Transactions — manual commit mode

This is the single most important behavioural difference between DBCraft’s SQL editor and its other panels. Read this section.

The SQL editor runs in manual-commit mode. It holds one long-lived Oracle session whose transaction spans your statements. Nothing you write with INSERT, UPDATE, DELETE or MERGE is durable until you commit.

ConceptDetail
Pending workWhen the session holds uncommitted DML, the ⎇ Commit icon turns green, the ↩ Rollback icon turns amber, and the status bar shows an amber Uncommitted segment.
Commit⎇ toolbar button, or palette → Commit. A notification confirms the result.
Rollback↩ toolbar button, or palette → Rollback.
DDL commits implicitlyOracle commits automatically on DDL. If you run a CREATE, ALTER or DROP, any pending DML is committed with it. The pending indicator is read from the database itself, so it always reflects reality.
Failed statements do not discard earlier workIf statement 5 fails, statements 1–4 remain pending.
Switching modules is safeThe transaction lives on the local service, not in the panel. Clicking away to Reports and back does not roll anything back.
Closing the window rolls backClosing the application tells the service to abandon the session, which rolls it back and releases the row locks immediately rather than waiting for a timeout.
Idle sessions are reapedA session left idle for 30 minutes is closed (and therefore rolled back).

Other panels do not see your uncommitted rows. Reports, the Object Viewer’s Data tab, the Terminal, the Test Manager and every DBA panel use separate auto-committed connections. If a report does not show a row you just inserted, you have not committed it.

Uncommitted DML holds row locks. Other users’ sessions can block behind yours. If the Session Browser shows blocking chains pointing at your session, commit or roll back.

#16.7Query history

The 🕘 toolbar button opens the history dropdown: up to 50 recent statements, newest first, each with the time it ran and how many rows it returned.

  • Click an entry to open it in a new tab.
  • Click the star to mark a favourite — favourites sort to the top.
  • Search the history with the box at the top of the dropdown.

Keyboard history recall. With the cursor in the editor:

  • Ctrl+↑ or Alt+↑ — step back through history into the current tab.
  • Ctrl+↓ or Alt+↓ — step forward; stepping past the newest restores what you had typed.

If the tab is empty, plain and do the same thing.

#16.8Snippet library

The ⭐ toolbar button opens a three-group library. Choosing a snippet opens it in a new tab named after the template.

Basic Queries (DML) — SELECT, INSERT (with sequence NEXTVAL), UPDATE, DELETE, INNER/LEFT JOIN templates.

Structure (DDL) — CREATE TABLE (with an identity column, unique constraint, default and timestamp), CREATE PROCEDURE (with IN/OUT parameters), CREATE FUNCTION (with an exception handler), CREATE TRIGGER (row-level BEFORE INSERT).

DBA & Metadata — Show DB version (v$version), List tables & sizes (user_segments), Find invalid objects (user_objects), Inspect table columns (user_tab_columns).

#16.9Visual Query Builder

The ⛓ toolbar button opens a point-and-click SELECT builder.

  1. The left column lists the tables in your schema. Hover a table and click + to add it to the canvas.
  2. Each added table appears as a card listing its columns. Click columns to tick them.
  3. The Generated SQL Preview at the bottom updates live.
  4. Insert SQL into Editor opens the generated statement in a new tab.

The builder produces the SELECT list and FROM clause. Add joins and predicates in the editor afterwards.

#16.10File operations

ActionToolbarBehaviour
Open📂Native file dialog; accepts .sql, .pks, .pkb, .txt. The file opens in a new tab named after the file.
Save💾Saves the active tab to a .sql file named after the tab, and clears its modified dot.
Save As…💾↓Native save dialog; you choose the name and folder. The tab is renamed to match.
Save all tabs💾⧉Writes every open tab to its own .sql file.