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

# Run Ad-Hoc SQL Queries with the Nexalytica Work Bench

> Write and run SQL directly against your connected data sources, save queries as sessions, and read results — all without an AI agent in the loop.

The Work Bench is Nexalytica's hands-on SQL workspace for analysts who want to query data directly, without an AI agent interpreting their intent. You write the SQL, you choose the source, and you get the raw results back. It is built for exploratory analysis, debugging, and one-off queries that do not need to become full dashboards. No configuration required — if you have platform access, the Work Bench is already available to you.

## Sessions

A session is a named scratchpad that remembers your SQL and the most recent result set. Sessions are personal to the browser and device you are using — they are not synced to the cloud or visible to other users. The Work Bench is not available via the Nexalytica API; sessions exist only in the browser.

### Create and manage sessions

From the sessions list on the left side of the Work Bench, you can create and organise your saved queries.

| Control                | How to trigger                           | What it does                                                                                                                       |
| ---------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **New session**        | Click **New session** button             | Creates a blank session and opens it in the editor                                                                                 |
| **Open session**       | Click the session card                   | Opens the session in the current tab                                                                                               |
| **Open in background** | **Ctrl / Cmd-click** or **middle-click** | Opens the session in a background tab                                                                                              |
| **Open with keyboard** | Focus card, press **Enter** or **Space** | Opens the session in the current tab                                                                                               |
| **Rename**             | Three-dot menu → **Edit**                | Renames the session                                                                                                                |
| **Share (copy SQL)**   | Three-dot menu → **Share**               | Copies the session's SQL to your clipboard. Because sessions are browser-local, sharing means sending the query text — not a link. |
| **Delete**             | Three-dot menu → **Delete**              | Permanently deletes the session after a confirmation prompt. There is no Trash — deletion cannot be undone.                        |

<Warning>
  Session deletion is permanent. The Work Bench does not move deleted sessions to Trash. Confirm you no longer need the SQL before deleting.
</Warning>

## Write and run SQL

Open a session to access the SQL editor. The editor occupies the main area of the Work Bench.

### Reference a data source

Instead of typing table names from memory, use the `@` mention shortcut to insert a fully-qualified table reference.

<Steps>
  <Step title="Type @ in the SQL editor">
    A source picker appears listing every connected SQL-compatible data source you have access to.
  </Step>

  <Step title="Select a source">
    Use the **arrow keys** to navigate the list, then press **Enter** or **Tab** to select. Press **Escape** to close the picker without selecting.
  </Step>

  <Step title="Select a table">
    A second picker lists the tables within the chosen source. Select the table the same way.
  </Step>

  <Step title="Reference inserted">
    Nexalytica inserts the fully-qualified table reference at the cursor position. Continue writing your query around it.
  </Step>
</Steps>

<Tip>
  The `@` picker only lists sources you have access to. If a source you expect is missing, check with your data administrator that you have been granted viewer access or higher on that source.
</Tip>

### Keyboard shortcuts

| Shortcut                                       | Action                   |
| ---------------------------------------------- | ------------------------ |
| **Ctrl+Enter** (Windows / Linux)               | Run the current query    |
| **⌘↵** (Mac)                                   | Run the current query    |
| **Ctrl+Enter / ⌘↵** *(while query is running)* | Cancel the running query |

### Editor controls

| Control  | Behaviour                                                                                                   |
| -------- | ----------------------------------------------------------------------------------------------------------- |
| **Run**  | Submits the query. The button label cycles: **Run → Starting… → Stop** while the query is in progress.      |
| **Stop** | Cancels a running query. The results table shows a cancellation explanation.                                |
| **Save** | Saves the current SQL and the latest result to the session. Only enabled when SQL is present in the editor. |

## Read query results

Results appear in the panel below the editor immediately after a query completes.

### Status badges

| Badge       | Meaning                              |
| ----------- | ------------------------------------ |
| `Queued`    | Query is waiting to be picked up     |
| `Running`   | Query is actively executing          |
| `Succeeded` | Query completed and returned results |
| `Failed`    | Query encountered an error           |
| `Cancelled` | Query was stopped before completing  |

### Results table

| Element             | Description                                                                                                                                                     |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Row count**       | Total number of rows in the result set                                                                                                                          |
| **Elapsed time**    | Query execution time in milliseconds                                                                                                                            |
| **Truncated badge** | Amber badge shown when the result has been capped at the Work Bench row limit. The full result is larger than what is displayed.                                |
| **Error banner**    | Red banner with the error message when the query status is `Failed`                                                                                             |
| **Results grid**    | Rows with row numbers. Displays **No rows** when the query succeeded but returned an empty set. Displays a cancellation explanation when the query was stopped. |

<Note>
  The Work Bench caps the number of rows returned per query. There is no per-page pagination and no one-click CSV export in this view. If your results show a truncated badge, tighten your query with a `WHERE` clause or a `LIMIT` to bring the result set within the cap.
</Note>

## Permissions reference

<Accordion title="All platform users">
  * Open the Work Bench and create sessions
  * Write and run SQL against any data source they can access
  * Save, rename, share (copy SQL), and delete their own sessions
  * Sessions are private and browser-local — other users cannot see them
</Accordion>

<Accordion title="Data source access">
  Query access is governed by your permissions on each data source. The `@` mention picker only lists sources you can access. Running a query against a source you do not have access to returns an error.
</Accordion>
