> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-feat-sql-code-folding.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

Every open connection lives in one window, and each connection has its own set of tabs. A tab strip appears in the window chrome, below the toolbar and lined up with the content pane, as soon as a connection holds more than one tab, and lists only that connection's tabs. With a single tab there is no strip, so a window that behaves the way it always did gains no chrome.

Each tab keeps its own SQL, results, sorting, and filter state. Tabs persist across app restarts.

A tab is named after the object it shows. When two tabs would carry the same name from different databases, both names gain the database: two tabs called `orders` become `app.orders` and `staging.orders`. A name no other tab uses stays short. Hovering a tab names its database either way, and VoiceOver reads the same.

<Frame caption="Tab strip with query and table tabs">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-sql-code-folding/VLUDsoMaXL0TA-5F/images/tabs.png?fit=max&auto=format&n=VLUDsoMaXL0TA-5F&q=85&s=e487bce924e9d0a06c15be0d9afe66b0" 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-feat-sql-code-folding/VLUDsoMaXL0TA-5F/images/tabs-dark.png?fit=max&auto=format&n=VLUDsoMaXL0TA-5F&q=85&s=b666078c3e76ee044703d7c382f7fc5e" 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) |

Table tabs track cell edits as pending changes by default. Query tabs support [change tracking](/features/change-tracking) when the query is a SELECT from one table, with or without `WHERE`, `ORDER BY`, or `LIMIT`. Joins, table aliases, and schema-qualified names like `public.users` come back read-only.

## Preview Tabs

Clicking a table opens it right away, in a preview tab that is reused when you click a different table, like VS Code's preview tabs. A tab with unsaved edits, an applied filter, or sorting is never replaced: the click opens a new tab instead. A preview tab still open at quit is restored as a permanent tab.

Double-click a table, or select it and press `Return`, to keep its tab. The tab stops being a preview and the next table you click opens in its own tab, so double-clicking your way down a list gives you one tab each. Double-clicking a table that is already open switches to its tab rather than opening a second one. A preview tab also becomes permanent on its own once you interact with it: sort it, filter it, or edit data.

Opening a table from Favorites always gives it a permanent tab, since selecting a favorite does not open it and the double-click, `Return`, or **Open Table** that does is deliberate.

Turn preview tabs off with **Settings > General > Tabs > Enable preview tabs** if you prefer every click to open a permanent tab.

## Two Tabs on One Table

**Open in New Tab**, on the table's contextual menu in the object browser, opens another tab for a table you already have open. The two tabs are independent, so you can filter, sort, and page one without touching the other, which is how you compare a table under two sets of conditions side by side.

Per-table filters are saved per connection, database, schema, and table rather than per tab, so the filter that comes back when you next open the table is whichever of the two you set last.

## Managing Tabs

### Creating and Closing

| Action                                  | How                                                                                                                                                                                                 |
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| New query tab                           | `Cmd+T` or the **+** button at the end of the tab strip                                                                                                                                             |
| New table tab                           | Click a table in the sidebar (the preview tab is reused), double-click it or press `Return` to keep its tab, or **Open in New Tab** on its contextual menu for a second tab on a table already open |
| Close tab                               | `Cmd+W`, the tab's close button, or **Close Tab** on the tab's contextual menu                                                                                                                      |
| Close other tabs                        | **File > Close Other Tabs**, or **Close Other Tabs** on the tab's contextual menu                                                                                                                   |
| Close every tab for the connection      | **File > Close All Tabs**, or **Close All Tabs** on the tab's contextual menu                                                                                                                       |
| Close tabs belonging to other databases | **File > Close Tabs for Other Databases**                                                                                                                                                           |

Right-clicking a tab gives you the three close commands for that tab without leaving the strip.

The three bulk commands have no shortcut out of the box. Bind them in **Settings > Keyboard** under Navigation.

Closing the last tab leaves the connection open on its empty state rather than closing anything. `Cmd+W` again closes the connection, and closes the window once that was the last connection open. So the shortcut reads the same way it does everywhere else: it closes the smallest thing in front of you first.

**Close Tabs for Other Databases** closes only tabs opened against a database other than the one the connection is on now. It never touches the tab you are looking at, and it is limited to the current connection. Tabs from different databases are meant to coexist, so switching databases never closes anything on its own. On engines that switch schemas instead of databases, such as BigQuery and Oracle, the command reads **Close Tabs for Other Schemas**.

Closing a query tab keeps its SQL in Recently Closed, so an accidental close costs nothing, including when you close a whole group at once. That is why a tab holding only typed query text closes without asking: the text comes back.

TablePro asks before closing when unsaved work would be lost, and the prompt offers Save, Cancel and Don't Save. It covers unsaved cell edits in a table tab, a `.sql` file that differs from what is on disk, staged structure and Create Table changes, and staged user and role changes. Save closes the tab once the save lands, except for user and role changes, where Save opens the review sheet instead and leaves the tab open until you execute or discard there. A bulk close asks once, and cancelling stops the rest.

Closing a tab you are not looking at selects it first, so the prompt is about work you can see before you answer it.

A tab whose work would raise that prompt shows an unsaved dot on the tab, so nothing is ever marked clean and then asks to be saved.

<Note>
  Tabs cannot be pinned or dragged to reorder. Pinning exists for result tabs inside a query tab (`Cmd+Option+P`, see [Keyboard Shortcuts](/features/keyboard-shortcuts)).
</Note>

### Reopening Closed Tabs

| Action                     | How                                           |
| -------------------------- | --------------------------------------------- |
| Reopen the last closed tab | `Cmd+Shift+T` or **File > Reopen Closed Tab** |
| Reopen an older tab        | **File > Recently Closed**                    |

The last 20 closed query and table tabs are kept for 30 days. A reopened tab comes back with its SQL, cursor position, and database context. Deleting a connection also deletes its closed tabs.

### Switching Tabs

* `Cmd+1` through `Cmd+9` jump to a tab by position
* `Cmd+Shift+[` / `Cmd+Shift+]` for previous and next tab
* **Window > Show Previous Tab** and **Window > Show Next Tab** do the same from the menu

Each tab keeps its full state when you switch away: SQL, cursor position, results, scroll position, sort and filter state, and pending changes. Selecting a tab that is scrolled out of sight pulls it back into view.

## Windows and Connections

One window hosts every connection you have open. Picking a connection in the [connections strip](/features/workspace-rail) switches that window to it and returns you to the tab you last used there, rather than raising a second window. Opening a table or query on a connection you already have open adds a tab to that connection instead of opening another window.

New windows open at 1200x800; size and position are remembered across launches.

### Separate Windows

You can still have more than one window, for putting two connections side by side. TablePro follows your **Prefer tabs when opening documents** setting in System Settings > Desktop & Dock rather than forcing a choice. When that setting is **Always**, new windows join a tab group and the standard commands apply:

| Action                                       | How                                 |
| -------------------------------------------- | ----------------------------------- |
| Move the current window out of its tab group | **Window > Move Tab to New Window** |
| Gather every window into one tab group       | **Window > Merge All Windows**      |

Both dim when the window is not part of a tab group. These are macOS window tabs, which is a different thing from the editor tab strip below the toolbar: window tabs hold whole windows, the strip holds one connection's editors.

### Disconnecting

**Database > Disconnect** ends the session without closing the window. The window shows a Reconnect screen in place of its tabs, and the tabs are saved before the session ends. Use **Database > Reconnect**, or the Reconnect button on the screen itself.

Reconnecting puts the tabs back as they were.

Disconnecting asks first only when there are unsaved changes or a query still running. It applies to the whole connection, so every window and entry on it shows the same Reconnect screen. Nothing reconnects on its own afterwards: a connection you disconnected is not reopened at the next launch, and clicking back into it leaves it disconnected until you ask.

You can also disconnect by right-clicking an entry in the [connections strip](/features/workspace-rail), or a connection in the connection list.

## Database Binding

A tab is bound to the connection, database, and schema it was opened on, fixed for the life of the tab. Every query, refresh, filter, sort, structure read, and structure save the tab performs uses that binding, not whatever the sidebar shows at the time.

The sidebar's database selection only controls two things: what the sidebar lists, and which database a new tab opens into. Changing it does not touch tabs that are already open, and switching between tabs does not change the connection's saved default database either.

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, and leaves the sidebar and every other tab alone.

The window subtitle shows the database, and the schema on engines that have one, that the frontmost tab is bound to. Tabs for the same connection can be bound to different databases, so the subtitle is how you tell them apart.

<Note>
  PostgreSQL, Redshift, and CockroachDB can only change database by reconnecting. A tab bound to a database other than the connection's active one runs its queries on a separate connection for that database, so it does not share temp tables, session variables, or an open transaction with the query editor on the main connection. See [PostgreSQL](/databases/postgresql#cross-database-tabs).
</Note>

## Tab Persistence

| 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                        |
| Column widths                              |                                      |
| Tab order and which tab was frontmost      |                                      |

Per-table filters are stored separately per connection, database, schema, and table, and come back when the table reopens.

Tab state saves when you switch tabs and every 30 seconds in the background, so a crash or force quit keeps recent work. On relaunch, only the frontmost tab loads its data right away; other restored tabs load the first time you switch to them, so launch stays fast and the database never sees a connection storm. If a restored tab fails to load, the error shows inline in that tab, not as a dialog. The same applies one level up: if the connection itself cannot be reached, the window shows why, with Try Again and Manage Connections, and keeps the connection in the next session's list so a server that was briefly down is not forgotten.

Whether the last session reopens at launch is controlled by [Startup Behavior](/customization/settings#general).

## Pagination

Table tabs load one page at a time. The default page size is 1,000 rows, set in **Settings > Data > Pagination** (100, 500, 1,000, 5,000, or 10,000 rows). Query tabs are not paginated: **Truncate query results** (on by default) caps results at 10,000 rows, and queries with their own `LIMIT` are sent as written. Adjust the cap in the same settings pane. See [Data Grid](/features/data-grid#pagination-and-limits) for the pagination controls.

## From External Clients

Raycast, Cursor, Claude Desktop, and other MCP clients can list and focus tabs:

* `list_recent_tabs` enumerates open tabs across every connection.
* `focus_query_tab` brings an existing tab to the front by id.
* `open_connection_window` opens a saved connection.
* `open_table_tab` opens a specific table.

The Raycast extension's [Recent Tabs command](/external-api/raycast#commands) wraps these tools. See [MCP Tools](/external-api/mcp-tools) for input and output schemas.
