> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-fix-linked-metadata-keeps-unknown-keys.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Files

> Open .sql files as query tabs, save back to them, and resolve edits made outside TablePro

Three ways in: double-click in Finder, **File > Open File…** (`Cmd+O`), or drag onto the Dock icon. `.sql`, `.psql` and `.pgsql` all work, and what you get is an ordinary query tab with a file behind it.

`Cmd+O` is not restricted to those three. It offers every file TablePro reads, and each one goes where its type belongs: a query tab for SQL, a connection window for a database file, the [CSV inspector](/features/csv-inspector) for a `.csv`. A file whose name says nothing is enabled on its contents, so a SQLite database saved without an extension is selectable. The command works with no connection open, from the welcome window too.

## Opening

Each file opens in a new tab. Opening one that is already open focuses its existing tab instead of making a second, and files opened before any connection exists wait in a queue until you connect.

The title bar carries the filename, and the close button gets the standard macOS unsaved-changes dot.

## Saving

`Cmd+S` saves back to the source file, and does a Save As when the tab has no file yet. `Cmd+Shift+S` always opens Save As.

`Cmd+click` the title bar for the standard path menu, then pick a folder to open it in Finder.

When a tab has both unsaved file changes and pending data grid edits, `Cmd+S` saves the grid changes first. Press it again once that finishes to save the file.

Closing a query tab keeps its SQL either way. Reopen it with `Cmd+Shift+T` or **File > Reopen Closed Tab**. See [Tabs](/features/tabs).

## When the file changes underneath you

An open file is compared with the copy on disk whenever its window becomes active, and whenever a [linked SQL folder](/features/favorites#linked-sql-folders) sees a change. Any difference counts: a `git pull`, an edit in another editor, or an older copy restored over it.

A changed file puts a yellow banner across the top of the tab, with a **Reload** button that replaces your tab's contents with what is now on disk. Close the banner and it stays closed until the file changes again.

Saving over a file that changed since you opened it opens a diff sheet instead of overwriting. **Your Changes** and **On Disk** sit side by side, and three buttons resolve it: **Keep My Changes**, **Reload from Disk**, or **Cancel**.

A file deleted, renamed, or moved to the Trash gets the same banner with **Save As** in place of **Reload**. The tab keeps its text, and `Cmd+S` opens Save As instead of writing the file back to its old path. Choosing **Save** as you close the tab opens Save As too, and the tab closes once the new file is written.

## A folder at a time

To watch a whole directory of `.sql` files rather than opening them one by one, use [Linked SQL Folders](/features/favorites#linked-sql-folders).
