Custom database queries can be executed from the SQL Query view in Postico. You can get to the SQL Query View by clicking on a query file in the sidebar. There's also a keyboard shortcut (⇧⌘T) to navigate to the query view.
The query view highlights the current statement in light grey. Use the command "Execute Query" in the "Connection" menu or press ⌘↩︎ to execute the current statement (or the current selection, if any). The corresponding results are displayed below the text view.
You can execute multiple statements at once by selecting them. They will be executed in an implicit transaction, so if one of the statements fails, all changes to the database will be rolled back.
When you execute multiple statements, Postico will display the first result. You can switch between results using a popup menu button at the bottom left.
Use the command "Execute All Queries" in the "Connection" menu or ⌥⌘↩︎ to execute all statements at once.
To clear the result area, use the command "Clear Results" in the "Connection" menu or press ⌘K.
There are two autocomplete modes available in the SQL query view.
In the autocompletion window, use the arrow keys to select a completion, then hit the return key to confirm.
Multiple matches of the same suggestion will be grouped by type, use the left and right arrow keys to expand and collapse grouped suggestions.
Multiple selected lines can be indented at once.
Use the command "Shift Right" in the "Edit" menu or press ⇥ or ⌘] to shift the selected line(s) to the right (increase indentation).
Use the command "Shift Left" in the "Edit" menu or press ⇧⇥ or ⌘[ to shift the selected line(s) to the left (decrease indentation).
Postico 2 includes pgFormatter for formatting SQL Queries. The default shortcut is Ctrl-F.
The query is formatted locally and is not sent to a web service.
If you have Dash installed, you can use the command "Look Up In Dash" in the context menu or press Ctrl-H to look up the current word (or selection) in Dash.