> ## Documentation Index
> Fetch the complete documentation index at: https://pgconsole-docs-faq-apache-license.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Editor

pgconsole's SQL editor is a workspace for writing queries, browsing schemas, and working with results. What sets it apart:

* **Understands your SQL** — syntax highlighting, autocomplete, formatting, error detection, and function signature help are all backed by a PostgreSQL parser, not regex.
* **Guardrails** — [database access control](/features/database-access-control) and [audit logs](/features/audit-log) ensure every query is authorized and recorded.
* **AI assistant** — generate, explain, fix, and rewrite SQL with an [AI assistant](/features/ai-assistant) that understands your schema context.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-overview.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=549a98734eeff3d9df13e2337dd5a851" alt="SQL Editor overview" width="2880" height="1800" data-path="images/features/sql-editor/sql-editor-overview.webp" />

## Editor

### SQL Intelligence

The editor parses your SQL in real-time to provide:

* **Autocomplete** — context-aware suggestions for tables, columns, joins, and CTEs (`Ctrl+Space`)
  <img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-autocomplete.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=5d0ed159cda7ebcc058ec4234e7e8ef3" alt="Autocomplete suggestions" width="1600" height="1200" data-path="images/features/sql-editor/sql-editor-autocomplete.webp" />
* **Formatting** — pretty-print or collapse to one line
  <img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-format.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=541941dc46d8cbc8eaabe5c9f440b225" alt="SQL formatting" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-format.webp" />
* **Error detection** — red underlines with hover tooltips; optionally **Fix with AI**
* **Code folding** — collapse `SELECT`, `WITH`, and other blocks

### Quick SQL Generation

When a table or view is selected in the schema browser, the Quick SQL menu generates SQL templates and inserts them into the editor:

<Note>INSERT, UPDATE, DELETE, CREATE TABLE, and ALTER ADD COLUMN are only available for tables (not views).</Note>

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-quick-sql.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=52fa9fe8e3073ea53c459ae4f5d2fb11" alt="Quick SQL menu" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-quick-sql.webp" />

## Data Grid

Query results appear in the panel below the editor in a virtual-scrolling grid that handles large result sets efficiently.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-results.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=b19f9fac2175e90231eeb8dcf9ab0274" alt="Query results" width="868" height="347" data-path="images/features/sql-editor/sql-editor-results.webp" />

### Navigation

| Action              | Behavior                      |
| ------------------- | ----------------------------- |
| Click a row         | Open the row detail panel     |
| Double-click a cell | Start editing that cell       |
| `j` / `↓`           | Select next row               |
| `k` / `↑`           | Select previous row           |
| `Space`             | Pin or unpin the selected row |

Pinned rows stick to the top of the grid for easy comparison across large result sets.

### Inline Editing

With `write` permission, you can modify data directly in the grid. All changes are staged locally — nothing is committed until you explicitly execute.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-row-detail.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=572e0b1da6a427606005cf022b5fea59" alt="Row detail panel" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-row-detail.webp" />

| Action          | How                                                                         |
| --------------- | --------------------------------------------------------------------------- |
| Edit a cell     | Double-click the cell, or click the row and press Edit in the detail panel  |
| Add a row       | Click the **+** button in the results toolbar                               |
| Delete a row    | Right-click and select Delete, or use the Delete button in the detail panel |
| Duplicate a row | Right-click and select Duplicate (primary key fields cleared)               |

Staged changes are color-coded: green for new rows (INSERT), amber for modified rows (UPDATE), red with strikethrough for deleted rows (DELETE).

When changes are pending, a floating bar lets you **Preview** the generated SQL or **Discard** all changes. The preview modal shows syntax-highlighted INSERT/UPDATE/DELETE statements and optionally an AI-powered risk assessment before you **Execute All**.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-staged-changes.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=51c811a9251e3ea6a8b7edeb937c3ab8" alt="Staged changes preview" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-staged-changes.webp" />

### Data Export

* **Export to CSV** — downloads visible rows as a CSV file (requires `export` permission)
* **Copy as Markdown** — copies results as a markdown table to the clipboard

## Schema Inspection

Schema tabs provide detailed inspection of database objects.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-schema-tab.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=b9266bdf449a5cd0ee6f2c574dfbeeb4" alt="Schema tab" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-schema-tab.webp" />

## Active Sessions

The Processes button in the toolbar opens a modal showing active database connections. The list auto-refreshes periodically. With `admin` permission, a **Terminate** button appears on each row with a confirmation countdown.

<img src="https://mintcdn.com/pgconsole-docs-faq-apache-license/01pUPl7sjW8o74B_/images/features/sql-editor/sql-editor-processes.webp?fit=max&auto=format&n=01pUPl7sjW8o74B_&q=85&s=0678a5ddceddb86ebfc448d3521b4e0a" alt="Active processes" width="1440" height="900" data-path="images/features/sql-editor/sql-editor-processes.webp" />
