> ## 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.

# Favorites

> Mark tables as favorites and save frequently used queries with optional keyword shortcuts

The query you retype every Monday is worth saving once. Give it the keyword `dau`, and from then on typing `dau` in the editor expands the whole statement, with the cursor already where you need to fill something in.

The Favorites tab in the sidebar holds two sections, **Tables** for pinned tables and **Queries** for saved SQL, plus a **Team Library** on a Team license and any folders of `.sql` files you have linked.

## Table favorites

Hover a table row in the sidebar and a star appears at the end of it. Click the star to pin the table; a filled yellow star marks one that is already pinned, so it stays visible without hovering. Favorites move to the top of their section and appear under **Tables** in the Favorites tab.

Double-click a favorite there to open the table. Its right-click menu has **Open Table**, **Show ER Diagram**, and **Remove from Favorites**.

Favorites are scoped to the connection, database, and schema, and sync through [iCloud](/features/icloud-sync). One whose table does not exist in the database you are viewing is hidden rather than shown broken.

## Recent tables

Turn on **Settings > General > Sidebar > Show recent tables** for a **Recent** section at the top of the sidebar. It records the last 10 tables you opened per connection and database, most recent first; arrowing through preview tabs does not count. Click a row to reopen the table, or right-click to remove one entry or clear the list. Recents stay device-local and survive relaunches.

## Saving a query

| From                                     | How                                                |
| ---------------------------------------- | -------------------------------------------------- |
| The editor toolbar                       | Click the star above the editor, or press `Cmd+D`  |
| Selected SQL                             | Right-click > **Save as Favorite**                 |
| [Query history](/features/query-history) | Right-click an entry > **Save as Favorite**        |
| The sidebar                              | **+** in the Favorites tab, then **New Favorite…** |

Give it a name, the SQL, and optionally a keyword and a scope. The **+** menu also carries **New Query**, **New Folder**, and **Add Linked SQL Folder…**

<Frame caption="Creating a new SQL favorite">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/sql-favorite-create.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=e53601a5404d392291f36a78a3347680" alt="Creating a new SQL favorite" width="1560" height="960" data-path="images/sql-favorite-create.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/sql-favorite-create-dark.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=14816decf81e06a05054054f02aa977a" alt="Creating a new SQL favorite" width="1560" height="960" data-path="images/sql-favorite-create-dark.png" />
</Frame>

A new favorite belongs to the connection you created it in. Select **Global** in the dialog to make it available in all connections, which is what you want for anything that does not name objects only one database has. Deleting a connection deletes the favorites scoped to it.

## Keywords

A keyword is a shorthand you type in the editor. Type its first letters, case does not matter, and it appears in the completion popup as a starred entry with the favorite's name; `Tab` or `Return` inserts the full SQL. Keywords must be unique inside their scope.

<Frame caption="Keyword expansion in the editor autocomplete">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/sql-favorite-keyword.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=d7f4163e2d1a0dc221bc76f3d6ad130b" alt="Keyword expansion in autocomplete" width="1560" height="960" data-path="images/sql-favorite-keyword.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/sql-favorite-keyword-dark.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=e338472262443359f1abb9aa055fd8c1" alt="Keyword expansion in autocomplete" width="1560" height="960" data-path="images/sql-favorite-keyword-dark.png" />
</Frame>

Typing a keyword in [Open Quickly](/features/open-quickly) finds the same query without touching the sidebar.

### Cursor placement

Put `;;` in the SQL to say where the cursor lands after expansion. The marker is removed on insert:

```sql theme={null}
SELECT COUNT(*)
FROM orders
WHERE orders.;;
```

Accepting that keyword leaves the cursor right after `orders.`, ready for a column name. Only the first `;;` counts; without one the cursor lands at the end.

## Working with saved queries

Double-click a favorite, or select it and press `Return`, to insert it into the editor. That is the default; **Run in New Tab** on the right-click menu runs it instead, and the same menu has **Copy Query**, **Edit…**, **Move to** for filing it in a folder, and **Delete**. Arrow keys move between rows, typing jumps to a name, and `Delete` removes the selection.

Create folders from the **+** menu, rename or delete them by right-clicking, and rename in place on the row. Dragging a saved query or a linked file out of the sidebar drops its SQL into the editor or another app.

## Team Library

On a Team license the Favorites tab gains a **Team Library** section holding queries your team shared. Double-click one, or select it and press `Return`, to run it in a new tab. To share yours, click **+ > Publish Saved Queries to Team…** See [Team Plan](/features/team).

## Linked SQL folders

Link a folder of `.sql` files on disk and they appear in the Favorites sidebar next to your saved queries. The point is a Git repo of shared queries: clone it, link it, and the team's queries stay one click away and current with `git pull`.

<Note>
  This is not [Linked Folders](/features/connection-sharing#linked-folders), which watches a folder of shared `.tablepro` connection files.
</Note>

Click **+** in the Favorites sidebar and choose **Add Linked SQL Folder…** Pick any folder; `.sql`, `.psql`, and `.pgsql` files are indexed, subfolders nest the way they do on disk, and hidden files are skipped. Folders are global, so every connection's Favorites tab shows them, and a large repo is fine: only the first 4 KB of each file is read to build the sidebar.

### Editing files

Click a linked file to open it as an ordinary editor tab. `Cmd+S` writes back in the file's original encoding, detected on load from UTF-8, UTF-16, ISO Latin-1, and a few others.

A file changed on disk after you opened it, by a `git pull` or a merge, shows a yellow banner above the editor with **Reload from Disk**. Save anyway and a side-by-side diff sheet offers **Keep My Changes**, **Reload from Disk**, and **Cancel**. Files added and removed outside TablePro reach the sidebar a second or two later on their own.

A non-UTF-8 file carries a yellow warning triangle in the sidebar. Saving keeps its encoding, and a character that does not fit, an emoji into ISO Latin-1, fails the save with an error rather than losing the character quietly.

### Frontmatter

Leading SQL comments set the display name, the keyword, and the tooltip:

```sql theme={null}
-- @name: Active Users (24h)
-- @keyword: dau
-- @description: Daily active users from the last 24 hours
SELECT user_id, last_seen
FROM users
WHERE last_seen > NOW() - INTERVAL 24 HOUR;
```

| Key            | Effect                                                                         |
| -------------- | ------------------------------------------------------------------------------ |
| `@name`        | Display name in the sidebar. Falls back to the filename without its extension. |
| `@keyword`     | Autocomplete trigger, exactly as for a saved favorite.                         |
| `@description` | Shown in tooltips. Optional.                                                   |

The parser stops at the first line that is not frontmatter, so these go at the very top; a UTF-8 BOM is handled. A file without frontmatter still appears, under its filename and with no keyword. The `;;` [cursor marker](#cursor-placement) works in linked files too.

To change frontmatter without opening the file, right-click the row and choose **Edit Metadata…** The dialog rewrites the leading comment block only and keeps the rest of the file and its encoding.

### Managing linked files

Press `Delete` on a linked file, or right-click > **Move File to Trash**: it goes to the macOS Trash and stays recoverable. Right-click a folder's root row for **Disable**, **Reload**, **Copy Path**, **Show in Finder**, **Add Another SQL Folder…**, and **Remove from Sidebar**. Removing unlinks the folder; the files stay where they are.

Linked folder paths are the one part of Favorites that does not sync, so each Mac links its own copy of a shared repo.
