Skip to main content

SQL Editor

Write and run SQL with tree-sitter syntax highlighting, schema-aware autocomplete, and multi-statement execution in a single editor pane.
SQL Editor

SQL Editor with syntax highlighting

Writing Queries

Separate statements with semicolons. Place the cursor in any statement and press Cmd+Enter to run just that one.
Select text and press Cmd+Enter to run only the selection. Multiple statements in a selection run sequentially:
  • On databases with transaction support, the batch runs in a transaction: if a statement fails, execution stops and all changes roll back. Databases without transactions run each statement as-is, with no rollback.
  • The error names the failing statement (“Statement 3/5 failed: …”).
  • The last SELECT result appears in the data grid.
  • Each statement is recorded individually in query history.
The editor supports multiple cursors for editing several places at once. Autocomplete suggests tables, columns, and keywords as you type, and resolves aliases. See Autocomplete. Use :name placeholders instead of hardcoding values; they bind via prepared statements. See Query Parameters.

Per-Tab Database Picker

The editor toolbar shows a database picker (or schema picker, depending on the engine). Each SQL tab binds to its own database:
  • Changing the picker affects only that tab. Switching the active database elsewhere keeps existing tabs on their bound database.
  • The picker lists the databases visible in the sidebar, so it follows the sidebar database filter.
  • Databases whose driver reconnects the session to switch show a lock instead of a menu; those tabs follow the connection’s active database.

Find and Replace

Press Cmd+F in a query tab to open the find panel. Switch the panel to Replace mode to replace the current match or all matches. Match modes: contains, matches word, starts with, ends with, or regular expression, plus match case and wrap around toggles.

Query Execution

Automatic Row Limit

SELECT and WITH queries without their own LIMIT or FETCH FIRST run with the configured row cap:
  • The default cap is 10,000 rows. Pick 100 to 500,000 in Settings > Data (Row cap), or turn off Truncate query results to disable it.
  • Your query is sent exactly as you wrote it. TablePro never changes the SQL, it stops reading once it reaches the cap.
  • Your own LIMIT, FETCH FIRST, or TOP always wins: the query is not capped for that run.
  • EXPLAIN, SHOW, writes, and DDL are never limited.
When the cap trims a result, the status bar shows truncated with a Fetch All link. To skip the cap for one run, press Cmd+Option+Enter or use the Execute button’s menu or the Query menu.

Results

Results appear in the data grid below the editor with row count and execution time. Large result sets are paginated.
  • Result tabs: every result gets a tab above the grid; multi-statement runs produce one tab per statement. Switch with Cmd+Option+[ / Cmd+Option+], close with Cmd+Shift+W. Hover a tab to see its query.
  • Pinning: right-click a tab and choose Pin Result, or press Cmd+Option+P. The next query lands in a new tab instead of overwriting the pinned one. Pinned tabs cannot be closed or cleared until unpinned.
  • Panel: toggle the results panel with Cmd+Option+R or the toolbar button; it auto-expands when a query executes. The toolbar trash button clears the query and results together; to keep the query, right-click the results and choose Clear Results.
  • Errors: a red banner above the results shows the database error message with a Fix with AI button.
  • Non-SELECT statements (INSERT, UPDATE, DELETE, DDL) show a success view with affected row count and execution time.

SQL Formatting

Press Cmd+Shift+L to format the current query. You can also click Format in the toolbar or use Query > Format Query; the shortcut is rebindable in Settings > Keyboard. The token-based formatter:
  • Breaks lines per clause (SELECT, FROM, WHERE, JOIN) and indents 2 spaces
  • Uppercases keywords
  • Preserves comments, string literals, and your cursor position
  • Keeps dialect identifier quoting (MySQL backticks, PostgreSQL double quotes)
  • Handles JOINs, subqueries, CASE expressions, CTEs (including recursive), window functions, and set operations
Procedural blocks (PL/pgSQL DO, stored procedures, T-SQL BEGIN/END) pass through with minimal changes. Before:
After:

Vim Mode

Enable Vim keybindings in Settings > Editor > Vim mode. Normal, Insert, Visual, and Command-line modes are supported, with standard motions, operators, count prefixes, and text objects. :w executes the query and :q closes the tab. Jump to a line with 10G or 10gg (:10 is not supported). Full key reference: Vim Mode.

Editor Settings

Settings > Editor covers line numbers, current-line highlight, word wrap, tab width, auto-uppercase keywords as you type, query parameters, and Vim mode. Editor font family and size are set per theme in Settings > Appearance. Editor windows remember their size, position, and font zoom between launches. See Query Tabs.

AI Assistance

Explain with AI (Cmd+L) explains the query at cursor, Optimize with AI (Cmd+Option+L) suggests performance improvements, and Fix with AI in the error banner rewrites a failing query. Inline AI suggestions (ghost text) complete your SQL as you type: Tab accepts, Escape dismisses. See AI Assistant for setup.

SQL Files

TablePro opens .sql, .psql, and .pgsql files:
  • Double-click in Finder (or Open With > TablePro)
  • File > Open File… (Cmd+O)
  • Drag files onto the dock icon
Files open in a new tab. Without a connection they queue and open on connect. Opening the same file twice focuses the existing tab.

Saving

  • Cmd+S saves back to the source file. Untitled tabs trigger Save As.
  • Cmd+Shift+S opens Save As.
The title bar shows the filename for file-backed tabs, with the standard macOS unsaved-changes dot on the close button. Cmd+click the title for the standard path menu, then pick a folder to open it in Finder. Closing a query tab keeps its SQL: reopen with Cmd+Shift+T or File > Recently Closed. See Tabs.
When a tab has both unsaved file changes and pending data grid edits, Cmd+S saves the grid changes first. Save the file after the grid save completes.

External Modifications

If a file changes on disk while open (a git pull, an edit in another editor), a yellow banner offers Reload from Disk, which replaces your tab edits with the new content. Saving over an externally changed file shows a side-by-side diff with three actions: Keep My Changes, Reload from Disk, or Cancel.

Linked Folders

To watch a whole folder of .sql files, use Linked SQL Folders instead of opening files one by one.