> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-feat-table-properties-tab.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Favorites

> Pin the databases and tables you keep returning to, save SQL, and link a folder of .sql files

The query you retype every Monday is worth saving once. Give it the keyword `dau`: type those three letters in the editor and the whole statement expands, cursor already in place.

The Favorites tab holds databases, tables, saved SQL, a **Team Library** on a Team license, and any linked folders of `.sql` files.

## Database favorites

| From                        | How                                                          |
| --------------------------- | ------------------------------------------------------------ |
| The sidebar, in Tree layout | Hover a database row and click its star                      |
| The database switcher       | Press `Cmd+K`, then right-click a row                        |
| The menu bar                | **Database > Favorite Database**, on the database you are in |

Start with the star. It lives only in the Tree layout (**View > Sidebar as Tree**), so use the menu bar in a flat list or from the keyboard.

The star files the database under **Unassigned**. A right-click sets the environment in one move: **Add to Favorites > Production**. Once a database is a favorite, that submenu reads **Environment**. Right-clicking inside a multiple selection acts on the whole selection.

In the Favorites tab, databases come first, one row per environment. The **Environment** menu narrows the list to one group; the search field filters by name. Double-click, or press `Return`, to switch to a database. Right-click for **Use as Active Database**, a different environment, or **Remove from Favorites**. `Delete` removes it too.

<Frame caption="Favorite databases grouped by environment">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-table-properties-tab/Ae_HE8knctkrWDpl/images/favorite-databases.png?fit=max&auto=format&n=Ae_HE8knctkrWDpl&q=85&s=8e836848976d6dea49bfa4a97dbf0428" alt="Favorite databases grouped into Development, Testing, and Production in the Favorites sidebar" width="3024" height="1722" data-path="images/favorite-databases.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-feat-table-properties-tab/Ae_HE8knctkrWDpl/images/favorite-databases-dark.png?fit=max&auto=format&n=Ae_HE8knctkrWDpl&q=85&s=0da508930f82ea2eec98f128fd297ebf" alt="Favorite databases grouped into Development, Testing, and Production in the Favorites sidebar" width="3024" height="1722" data-path="images/favorite-databases-dark.png" />
</Frame>

Database favorites belong to the connection, and go when you delete it. A dropped database stays in the list until you remove it.

## Table favorites

Hover a table row and click the star at its trailing edge, or right-click and choose **Add to Favorites**. A pinned row keeps its star, filled and yellow.

Pinned tables sit under **Tables** in the Favorites tab. Double-click, or press `Return`, to open one. Its right-click menu has **Open Table**, **Show ER Diagram**, and **Remove from Favorites**; `Delete` removes the selection.

Table favorites are scoped to the connection, database, and schema, and sync through [iCloud](/features/icloud-sync). One whose table is missing from the database you are browsing is hidden rather than shown broken.

## Recent tables

Turn on **Show recent tables** in [General settings](/customization/general-settings) for a **Recent** section at the top of the object list. It holds the last 10 tables per connection and database, newest first, and stepping through preview tabs records only the one you stop on.

Click a row to reopen the table. Right-click to remove one entry or clear the list. Recents stay on this Mac.

## Saving a query

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

The dialog takes a name, the SQL, and an optional keyword. Select **Global** for a query that names nothing specific to one database. Leave it off and the favorite belongs to the connection you are in, and goes with it when that connection is deleted.

<Frame caption="Creating a new SQL favorite">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-table-properties-tab/7-jNTh36bYtssbml/images/sql-favorite-create.png?fit=max&auto=format&n=7-jNTh36bYtssbml&q=85&s=912adee8a10e06d58d83e7302d12f4e2" alt="A dialog with Name, Query, Keyword fields and a Global checkbox" width="1560" height="960" data-path="images/sql-favorite-create.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-feat-table-properties-tab/7-jNTh36bYtssbml/images/sql-favorite-create-dark.png?fit=max&auto=format&n=7-jNTh36bYtssbml&q=85&s=0ccaf309428f4e6b6287b7f0b7d7450f" alt="A dialog with Name, Query, Keyword fields and a Global checkbox" width="1560" height="960" data-path="images/sql-favorite-create-dark.png" />
</Frame>

There is no plus button. The same right-click menu carries **New Query**, **New Folder**, and **Add Linked SQL Folder…**

## Keywords

A keyword is what you type instead of the query. Type its first letters, in any case, and the favorite appears in the completion popup with a star; `Tab` or `Return` inserts the SQL. See [Autocomplete](/features/autocomplete).

Two favorites in one scope cannot share a keyword, and the dialog says so as you type.

<Frame caption="Keyword expansion in the editor autocomplete">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-table-properties-tab/7-jNTh36bYtssbml/images/sql-favorite-keyword.png?fit=max&auto=format&n=7-jNTh36bYtssbml&q=85&s=294531ac5556e07fc303b67185e555bf" alt="A completion popup with a starred favorite matching the typed keyword" width="1560" height="960" data-path="images/sql-favorite-keyword.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-feat-table-properties-tab/7-jNTh36bYtssbml/images/sql-favorite-keyword-dark.png?fit=max&auto=format&n=7-jNTh36bYtssbml&q=85&s=03f78c553629139ac4165d09789ee788" alt="A completion popup with a starred favorite matching the typed keyword" 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. The marker is removed on insert:

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

The cursor lands right after `orders.`, ready for a column name. Only the first `;;` counts; without one it lands at the end.

## Working with saved queries

Double-click a favorite, or press `Return`, to insert it into the editor. The right-click menu has **Insert in Editor**, **Run in New Tab**, **Copy Query**, **Edit…**, **Move to**, and **Delete**. Arrow keys move between rows, typing jumps to a name, and `Delete` asks first.

Folders come from the same background menu. A folder's own menu has **Rename**, **New Favorite…**, **New Subfolder**, and **Delete Folder**; deleting one moves what was inside up to the parent level. Drag a query or a linked file out of the sidebar to drop its SQL into the editor or another app.

## Team Library

On a Team license the Favorites tab gains a **Team Library** section holding what your team published. Double-click one, or press `Return`, to run it in a new tab.

To publish your own, right-click empty space and choose **Publish Saved Queries to Team…** It replaces everything you published before. See [Team Plan](/features/team).

## Linked SQL folders

Link a folder of `.sql` files on disk and they appear next to your saved queries. The point is a Git repo of shared queries: clone it, link it, and a `git pull` keeps the team current.

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

Right-click empty space, choose **Add Linked SQL Folder…**, and pick any folder. `.sql`, `.psql`, and `.pgsql` are indexed, subfolders nest the way they do on disk, and hidden files are skipped.

Linked folders are global, so every connection shows them. Only the first 4 KB of each file is read to build the sidebar, so a large repo stays cheap.

### Editing files

Click a linked file to open it as an ordinary editor tab. `Cmd+S` writes back in the encoding the file was read with, detected from the file itself and falling back to UTF-8, then ISO Latin-1.

A file changed on disk gets the same banner and diff sheet as any other [SQL file](/features/sql-files#when-the-file-changes-underneath-you). Files added and removed outside TablePro reach the sidebar a second later.

A non-UTF-8 file carries a yellow warning triangle. Saving keeps its encoding, and a character it cannot represent, an emoji in an ISO Latin-1 file, fails the save with an error rather than dropping the character.

### Frontmatter

Leading SQL comments set the 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 one of these, so they go at the very top. Keys are case-insensitive and a UTF-8 BOM is handled. A file without frontmatter appears under its filename with no keyword. The `;;` [cursor marker](#cursor-placement) works here too.

Right-click a row and choose **Edit Metadata…** to change frontmatter without opening the file. The dialog rewrites the leading comment block and leaves the rest, and the encoding, alone.

### Managing linked files

Press `Delete` on a linked file, or right-click and choose **Move File to Trash**: it goes to the macOS Trash and stays recoverable. The rest of that menu is **Open in Editor**, **Edit Metadata…**, **Copy Query**, and **Show in Finder**.

A folder's root row carries **Show in Finder**, **Copy Path**, **Disable**, **Reload**, **Add Another SQL Folder…**, and **Remove from Sidebar**. Removing unlinks the folder and leaves the files where they are.

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