> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-docs-fix-500-query-results.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Tabs

> Each tab keeps its own SQL, results, sorting, and filters, and comes back after a restart

Open a table while the sidebar is on `app` and that tab keeps querying `app`, and its schema, for the rest of its life. Changing the database in the sidebar moves what the sidebar lists and where the next tab opens; it retargets nothing already open.

The tab strip sits below the toolbar and lists only the current connection's tabs. One tab, no strip.

Tabs are named after the object they show. When two would draw the same name, both gain their database: two tables called `orders` become `app.orders` and `staging.orders`. A name nothing else uses stays short, and hovering names the database either way.

<Frame caption="Tab strip with query and table tabs">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/0TDhsORsgVLO0zL5/images/tabs.png?fit=max&auto=format&n=0TDhsORsgVLO0zL5&q=85&s=6c3e222937f4093c76f4ca1a37d34a50" alt="Tab strip with query and table tabs" width="1560" height="960" data-path="images/tabs.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/0TDhsORsgVLO0zL5/images/tabs-dark.png?fit=max&auto=format&n=0TDhsORsgVLO0zL5&q=85&s=38b626ef9a80e16a85c02c8780c41db6" alt="Tab strip with query and table tabs" width="1560" height="960" data-path="images/tabs-dark.png" />
</Frame>

## Tab types

| Type          | Purpose                                                                        |
| ------------- | ------------------------------------------------------------------------------ |
| **Query tab** | Write and run SQL                                                              |
| **Table tab** | Browse table data with pagination, sorting, and [filters](/features/filtering) |

Both stage cell edits as pending changes. A query tab does it only when its query is a SELECT from one table; joins, aliases, and schema-qualified names like `public.users` come back read-only. See [Change Tracking](/features/change-tracking).

## Keys

| Action                     | Shortcut                |
| -------------------------- | ----------------------- |
| New query tab              | `Cmd+T`                 |
| Close the current tab      | `Cmd+W`                 |
| Reopen the last closed tab | `Cmd+Shift+T`           |
| Go to a tab by position    | `Cmd+1` through `Cmd+9` |
| Previous tab               | `Cmd+Shift+[`           |
| Next tab                   | `Cmd+Shift+]`           |

**Close Other Tabs**, **Close All Tabs**, and **Close Tabs for Other Databases** ship unbound. Bind them in **Settings > Keyboard** under Navigation.

## Preview tabs

Clicking a table opens it immediately in a preview tab, which the next click reuses. Double-click a table, or select it and press `Return`, to keep its tab: the next table then opens in one of its own, so double-clicking down a list gives you a tab each. Double-clicking a table already open switches to its tab.

A preview tab turns permanent as soon as you sort it, filter it, or edit data, and a tab in any of those states is never replaced by a click. One still open at quit comes back permanent, and a table opened from Favorites is permanent from the start. Turn the behavior off in **Settings > General > Tabs > Enable preview tabs**.

## Two tabs on one table

**Open in New Tab**, on the table's contextual menu in the sidebar, opens a second tab for a table already open, and the two are independent: filter, sort, and page one without touching the other. Per-table filters are stored per table rather than per tab, so the one that comes back next time is whichever of the two you set last.

## Closing tabs

| Action                               | How                                                                      |
| ------------------------------------ | ------------------------------------------------------------------------ |
| Close one tab                        | `Cmd+W`, the tab's close button, or **Close Tab** on its contextual menu |
| Close the rest                       | **File > Close Other Tabs**, also on the tab's contextual menu           |
| Close every tab for this connection  | **File > Close All Tabs**, also on the tab's contextual menu             |
| Close tabs bound to another database | **File > Close Tabs for Other Databases**                                |

Closing the last tab leaves the connection open on its empty state. `Cmd+W` again closes the connection; [Keyboard Shortcuts](/features/keyboard-shortcuts#tabs-and-windows) has the rest of that cascade.

**Close Tabs for Other Databases** takes only tabs opened against a database other than the one the connection is browsing now, never the tab in front of you, and never another connection's tabs. On engines that switch schemas instead, such as BigQuery and Oracle, it reads **Close Tabs for Other Schemas**.

Closing asks **Do you want to save changes?** when the tab holds unsaved cell edits, a `.sql` file that differs from disk, or staged structure, Create Table, or user and role changes. Save closes the tab once the save lands, except for user and role changes, where it opens the review sheet instead and leaves the tab open. A bulk close asks once, and Cancel stops the rest. A tab you are not looking at is selected first, putting the work in front of you before you answer.

A dot on the tab marks unsaved text or unsaved edits. It is deliberately wider than the prompt: a scratch query tab shows the dot and still closes without asking.

## Reopening closed tabs

`Cmd+Shift+T`, or **File > Reopen Closed Tab**, brings back the last query or table tab you closed, with its SQL, cursor position, and database context. The last 20 are kept for 30 days, and deleting a connection deletes its closed tabs with it. Server Dashboard, Users & Roles, and structure tabs are not candidates.

Pending cell edits are the one thing that does not come back: they are never written to disk, so **Don't Save** on the close prompt is final.

## Reordering tabs

Drag a tab along the strip to move it; the others slide out of the way. Right-click a tab for **Move Tab Left** and **Move Tab Right**, which move it one place at a time, dim at the ends of the strip, and are offered to VoiceOver as actions on the tab.

<Note>
  Tabs cannot be pinned. Pinning exists for result tabs inside a query tab (`Cmd+Option+P`).
</Note>

## Switching tabs

`Cmd+1` through `Cmd+9` jump by position, `Cmd+Shift+[` and `Cmd+Shift+]` step, and **Window > Show Previous Tab** and **Window > Show Next Tab** do the same from the menu bar. A tab scrolled out of sight is pulled back into view. Switching keeps SQL, cursor, results, scroll position, sort, filters, and pending changes.

Loaded rows are the exception, and only in bulk. Background table tabs keep their rows up to a budget read from the Mac's memory: two under 8 GB, three at 8 GB, five at 16 GB, eight at 32 GB or more, halved under memory pressure. Past that, the tabs you touched longest ago drop their rows and re-query when you return. Thirty table tabs cost one query on return, not thirty resident result sets.

## Where a tab points

A tab is bound to one connection, database, and schema, and every query, refresh, filter, sort, structure read, and structure save it runs uses that binding. Switching tabs never changes the connection's saved default database. To point an existing tab somewhere else, use the database picker in the query editor's toolbar: it rebinds that one tab and reruns it.

The window subtitle names the frontmost tab's database, and its schema on engines that have one. That is how you tell two tabs on one connection apart.

<Info>
  PostgreSQL, Redshift, and CockroachDB change database only by reconnecting, so a tab bound to a second database runs on its own connection: no shared temp tables, session variables, or open transaction. See [PostgreSQL](/databases/postgresql#cross-database-tabs).
</Info>

## What survives a restart

| Saved                                      | Not saved                           |
| ------------------------------------------ | ----------------------------------- |
| SQL and cursor position                    | Query results, re-queried on reopen |
| Tab type, table name, database, and schema | Pending data changes                |
| Applied sort and current page              | Selected rows                       |
| Per-table filters, column widths           |                                     |
| Tab order and which tab was frontmost      |                                     |

The tab set is written when you switch tabs, a second after you stop typing, and every 30 seconds otherwise, so a crash costs at most the last half minute. On relaunch only the frontmost tab runs its query; the others load the first time you switch to them, and one that fails shows the error inline. A connection that cannot be reached shows the driver's error with **Try Again**, **Manage Connections…**, and **Copy Details**, and stays in the next session's list. Whether the last session reopens at all is [Startup Behavior](/customization/general-settings#startup).

## Row limits

Table tabs page; query tabs stop at a row cap. Both limits, and what **Fetch All** does about them, are in [Settings > Data](/customization/data-settings).

## From external clients

MCP clients list open tabs with `list_recent_tabs`, bring one forward by id with `focus_query_tab`, and open new ones with `open_table_tab` and `open_connection_window`. See [MCP Tools](/external-api/mcp-tools) for the schemas, and Raycast's [Recent Tabs](/external-api/raycast#commands) command.

## Related

* [Connections strip](/features/workspace-rail) for switching connection and for disconnecting
* [Keyboard Shortcuts](/features/keyboard-shortcuts) for every default binding
