Query Favorite & Keyword Binding
Last updated
Last updated
There are some queries you want to reuse in different contexts or with different objects quite frequently. You can add it to favorite and assign a keyword for reference and call it quickly using that keyword later.
To add a new favorite query:
Right click on the Favorite section on the left sidebar.
Choose New
> File...
From the popup editor window, name the query and its binding keyword
Press ⌘ + S
to save the changes and then close the window.
To add a query to favorite from the Editor or from the History:
Select the query from the editor (you can also choose from History tab)
Right-click and choose Add to favorite
From the popup editor window, name the query and its binding keyword
Press ⌘ + S
to save the changes and then close the window.
Later, when you want to use a favorite query, type the assigned keyword and TablePlus will insert that query into the editor.
To use a query from Favorite from the Editor, type the assigned keyword and hit Enter, the query will be inserted.
Or you can find the query in the Favorite and choose:
Run
to execute the query in a new tab
Copy
to copy the query to the clipboard, you can also select it and use shortcut key ⌘ + C
then paste it to the Query Editor.
Import...
to use the favorite query via the SQL Import Wizard.
Open in anew tab
to open Query Editor in a new tab and insert the query into it.
Insert to SQL Editor
to insert the query into the current Query Editor.
To open a favorite query in a separate SQL Viewer and edit its code, name, and keyword, right click on the query and choose Edit/Rename
. When the edit is done, press ⌘ + S
to save it.
To avoid auto saving queries while editing it in the Query Editor, go to Preferences (Cmd + ,) and unselect the Auto save queries while editing
option in the General tab.
You can also change this via the dropdown menu at the bottom of the left sidebar
To delete a query from Favorite, right click on the query and choose Delete
To see the location of the SQL file that contains query, right click on the query and choose Show in Finder
Favorite queries can be grouped into folders.
To create a new favorite folder, you can either:
Right click on the Favorite section and choose New
> Folder...
Or right click on the Favorite section and choose New
> Add Folder to Favorites...
, then select the query folder on your computer to import into Favorite.
To add a favorite query into a folder, drag and drop the query to the folder you want.
To rename a favorite folder, right click on the folder and choose Edit/Rename
To delete a favorite folder, right click on the folder and choose Delete
By default, when double click on the favorite query, TablePlus runs the query. You can change this default behaviour using the dropdown menu at the bottom of the left sidebar.
If you enable Double click to Insert Favorite
, when you double on a favorite query, TablePlus insert it to the current tab of Query Editor instead.
You can select/unselect Auto save Favorite
to enable/disable autosave while editing favorite queries