Skip to main content
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 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 encoding comes from the file: its byte order mark first, then the encoding a Mac app recorded for it when saving, then UTF-8. Bytes that fit none of those open as ISO Latin-1. 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.

File encoding

A save writes the file in the encoding it was opened in. A byte order mark stays, and UTF-16 and UTF-32 keep their byte order. A file known only by the encoding a Mac app recorded for it keeps that record. A file recorded as ASCII saves as UTF-8. If the text holds a character the encoding cannot store, such as an emoji in an ISO Latin-1 file, the save stops. An alert names the file and its encoding, the file on disk is left as it was, and the tab stays open with your text. This holds for Cmd+S, for Save when closing a tab or a window, and for closing several tabs at once. Save As always writes UTF-8, which is how to convert a file. The tab then points at the new file and keeps saving it as UTF-8.

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 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, with changed lines highlighted unless the changes span more than 2,000 lines. 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.