Query Editor
The Query Editor is the central workspace in Tablen for writing, editing, and executing SQL queries. It provides professional-grade editing features including syntax highlighting, intelligent autocomplete, SQL formatting, linting, and more.
Editor Features
Syntax Highlighting
The editor provides full SQL syntax highlighting with customizable themes. Keywords, strings, comments, numbers, and functions are highlighted in distinct colors. Theme colors can be customized through the plugin system.
Autocomplete
Tablen's autocomplete system offers context-aware suggestions as you type:
| Type | Label | Color | Description |
|---|---|---|---|
| Keyword | KEY | Blue | SQL keywords (SELECT, FROM, WHERE, etc.) -- 60+ keywords |
| Table | TBL | Orange | Table names from the connected database |
| Column | COL | Green | Column names from relevant tables |
| Function | FN | Red | SQL functions (COUNT, SUM, CONCAT, etc.) -- 30+ functions |
| Postfix | PFX | Purple | Postfix completions for common patterns |
Context-Aware Completions
The autocomplete system analyzes your query context to provide relevant suggestions:
- After SELECT: Suggests columns and functions
- After FROM: Suggests table names
- After JOIN: Suggests table names
- After WHERE: Suggests columns and operators
- After dot (table.column): Suggests columns from the specified table or alias
- General context: Suggests all available completions
Alias Resolution
The autocomplete system resolves table aliases. If you write FROM users u and then type u., it will suggest columns from the users table.
Fuzzy Matching
Completions support fuzzy matching -- you don't need to type the exact prefix. Typing "sel" will match "SELECT", and "usr" can match "users".
Line Numbers
Line numbers are displayed in the gutter. Toggle in Settings > Appearance > Show Line Numbers.
Minimap
A minimap overview of your SQL code is available on the right side of the editor. Toggle in Settings > Appearance > Show Minimap.
Font Configuration
- Default font: Monospaced system font
- Default size: 13pt
- Adjustable from 10pt to 24pt in Settings > Appearance > Font Size
SQL Formatting
Format your SQL code with proper indentation and structure:
- Shortcut: Cmd+Shift+F
- Command Palette: Search for "Format SQL"
- Formatting respects the SQL dialect of your connected database
SQL Refactoring
Refactor SQL code for better readability and performance:
- Shortcut: Cmd+Shift+R
- Available refactoring suggestions depend on the query structure
SQL Linting
Real-time SQL linting checks your queries for common issues:
- Lint rules can be customized through the plugin system
- Rules have three severity levels: Error, Warning, Info
- Each rule includes: name, regex pattern, severity, message, suggestion, and optional database type filter
- Built-in plugins include safety-focused lint rules (e.g., SQL Safety Rules plugin)
Visual Query Builder
Build SQL queries visually without writing code:
- Shortcut: Cmd+Shift+Q
- Command Palette: Search for "Visual Query Builder"
- Select tables, columns, joins, and conditions through a visual interface
- The generated SQL is inserted into the query editor
Query Execution
Running Queries
- Execute: Cmd+Return (runs the current query or selected text)
- Execute via Command Palette: Search for "Execute Query"
- Results appear in the Result Table below the editor
Split Statements
When your editor contains multiple SQL statements separated by semicolons, Tablen can split and execute them individually.
Row Limit
Control the number of rows returned by queries:
- Options: 50, 100, 500, 1000, 5000
- Default: 100 (configurable in Settings > Appearance > Default Row Limit)
- Displayed in the query toolbar
Query Timeout
- Options: 15, 30, 60, 120 seconds
- Default: 30 seconds (configurable in Settings > General > Query Timeout)
- Uses a racing pattern with
withThrowingTaskGroupfor reliable timeout enforcement
Toggle Editor Visibility
- Shortcut: Cmd+E
- Show or hide the SQL editor pane
- Useful when you want to focus on results or the schema browser
Query History
Access your previously executed queries:
- Shortcut: Cmd+Y
- Command Palette: Search for "Query History"
- Stores the last 100 queries in UserDefaults
- Search and filter through past queries
- Click a history entry to load it into the editor
Favorite Queries
Save frequently used queries for quick access:
- Add to Favorites: Cmd+Shift+D
- View Favorites: Cmd+Shift+B
- Each favorite stores: name, SQL query, description, and optional database type filter
Saved Queries
Save queries with names and descriptions for future use:
- Saved queries persist across sessions
- Stored in
~/Library/Application Support/DBClient/saved_queries.json - Can be synced across devices via iCloud
Shared Queries
Share queries with your team (requires Team plan):
- Published queries are visible to all team members
- Includes version tracking and author information
Scheduled Queries
Schedule queries to run at specific intervals:
- Configure schedules in Settings > Schedules
- Set frequency, time, and target connection
- View execution history and results
Parameterized Queries
Write queries with parameters that are filled in at execution time:
- Use parameter syntax in your SQL
- Tablen parses parameters and prompts for values before execution
- Supports named parameters
Template Runner
Run predefined query templates with customizable parameters:
- Templates can be created as plugins (Snippets type)
- The Template Runner UI allows filling in template variables before execution
EXPLAIN Analysis
Analyze query execution plans:
- Run EXPLAIN on any query to see the execution plan
- The Explain Analyzer parses EXPLAIN output and highlights:
- Full table scans
- Missing indexes
- Estimated vs actual row counts
- Cost estimates
- Slow queries (>1 second) automatically trigger EXPLAIN analysis
Query Auto-Save
Queries are automatically saved as you type:
- Prevents data loss on unexpected app closure
- Auto-saved content is restored when you reopen the tab
Query Git Versioning
Track query changes with Git-like versioning:
- Query changes are versioned locally
- Browse and restore previous versions of your queries
Code Review Mode
When editing data inline in the result table:
- Shortcut: Cmd+S to commit changes
- When Code Review Mode is enabled (Settings > General > Safety), a preview of the generated SQL is shown before execution
- Review INSERT, UPDATE, or DELETE statements before they run
- Toggle in Settings > General > "Review SQL before committing inline edits"