> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dbhost.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Explorer

> Browse tables and run read-only SQL against a selected database.

The Data Explorer is available from each database detail page at `/dashboard/{id}/explorer`.

It is designed for quick inspection inside the dashboard, without replacing your normal database client. On the database detail page, DBHost also exposes a dedicated **SQL Explorer** action card so the query workspace stays prominent.

## Database context

At the top of the explorer, DBHost shows the current database context directly in the header card and includes a database switcher for every database you own that supports explorer access from the dashboard.

* The explorer is always connected to one selected database at a time
* Queries in the SQL editor already run against that selected database
* You do not need to prefix the database name in `FROM`
* If you want another database, switch explorer context first

Explorer access is limited to the database owner. Public API key scope does not control the in-dashboard explorer.

## Tabs

### Tables

The **Tables** tab lists public tables in the selected database and lets you preview rows with pagination.

* Only tables in the `public` schema are shown
* Row previews are paginated in the UI
* Table browsing is scoped to the database opened from the dashboard

### SQL Query

The **SQL Query** tab runs a single guarded read-only statement at a time.

It now includes an editor-first workflow built from live explorer context:

* An editor-first layout with query results directly below the SQL surface
* A companion utility rail with three panes: **Suggested**, **Saved**, and **Recent**
* Selected table context in the rail, including a live table picker and quick table chips
* One-click starter queries for previewing rows, counting rows, distinct previews, and `EXPLAIN` plans
* A slash command drawer inside the SQL editor when you type `/`
* Context-aware table completion when you use `/` after `FROM` or `JOIN`
* A quick `FROM <selected table>` action in the editor footer for simple `SELECT` statements
* A per-device editor settings menu so you can toggle slash commands, `FROM` / `JOIN` table suggestions, and the helper rail
* A safe `psql`-style inspect subset: `\dt`, `\dv`, `\di`, and `\d <relation>` (the explorer also accepts `/dt`, `/dv`, `/di`, and `/d <relation>`)

Inside the SQL editor, `FROM` expects a table name, not a database name. The explorer already chooses the database connection from the header switcher above.

The inspect commands above are explorer-native shortcuts, not raw SQL. They are resolved by the explorer before SQL parsing and stay limited to the selected database and the `public` schema.

Accepted inspect examples:

* `\dt`
* `\dv`
* `\di`
* `\d "analytics_downloads"`
* `\d FROM "analytics_downloads"`
* `/dt FROM "analytics_downloads"`

When you describe a relation with `\d` or `/d`, the result view shows:

* Columns, data types, nullability, and defaults in the main result grid
* Supplemental sections for indexes and relation metadata when available

### Saved, recent, and persistence

The helper rail keeps non-editor tasks out of the main writing surface:

* **Suggested** contains starter snippets based on the currently selected table
* **Saved** lets you save named SQL presets for the current database, mark favorites, edit them, and delete them
* **Recent** keeps the latest query history first for the current database and lets you tune the retention count for your account

The **Saved** pane highlights favorites first, then keeps the full saved-query list underneath. The **Recent** pane always shows the newest runs first, and loading one of them replaces the SQL currently in the editor so you can rerun or modify it.

Saved presets and recent history use server persistence when the latest explorer migration is available. If that migration is still pending, the rail falls back to browser-local storage until server-backed persistence is ready.

### Keyboard shortcuts

The editor supports these shortcuts:

* `/` opens the command drawer when slash commands are enabled
* `Esc` closes the open drawer or suggestion list
* `Ctrl+Enter` or `Cmd+Enter` runs the current query
* `Ctrl+C` clears the editor when no text is selected

Allowed statement types:

* `SELECT`
* `EXPLAIN SELECT`

Additional rules:

* Only one statement is allowed per run
* The explorer is limited to the selected database and the `public` schema
* System catalogs, system schemas, utility commands, and data-modifying statements are blocked

## What the explorer blocks

The explorer blocks destructive or escape-hatch SQL such as:

* `DROP`
* `TRUNCATE`
* `ALTER`
* `INSERT`
* `UPDATE`
* `DELETE`
* `CREATE TABLE`
* `CREATE INDEX`
* multi-statement batches
* transaction/session control statements
* explicit system-schema access

<Note>
  Explorer guardrails only apply here. Direct PostgreSQL connections still use
  your normal database credentials and privileges.
</Note>
