Help › Write SQL

Write and run SQL

What a query tab is, what the bar above the editor does, and where to read about writing, running and keeping SQL.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

You write SQL in a query tab. Each tab has its own editor, its own results and its own session on the database, so what you do in one tab (a transaction, a temporary table) does not show up in another.

This topic goes through a query tab from top to bottom. Each part has a topic of its own with the details.

Open a query tab

Choose File › New Query (⌘T on macOS or Ctrl+T on Windows and Linux), or use the + at the end of the tab bar. To start a tab on a particular connection or database, select it in the sidebar and choose Query › New Query on This Connection.

An empty editor says what to press: ⌘↩ on macOS or Ctrl+Enter on Windows and Linux runs the statement at the cursor, and ⌃Space on macOS or Ctrl+Space on Windows and Linux asks for suggestions.

The bar above the editor

ControlWhat it doesRead more
RunRuns the statement the cursor is in. Reads Running… while a query runs.Run statements and scripts
Run SelectionRuns the selected SQL, one statement after another.Run statements and scripts
CancelStops the running query.Run statements and scripts
Dry RunRuns the UPDATE or DELETE at the cursor without committing it, and shows the rows it would change.See a change before you commit it
Run on Several…Runs the statement at the cursor on several connections, into one grid.Run a query on several connections
Explain and AnalyzeShow how the database would run, or did run, the statement at the cursor.See a query's execution plan
FormatLays out the selected statements, or the whole tab.Format SQL
Save or Save…Saves the tab to its file or saved query, or asks where to keep it.Keep queries as saved queries, Open and save SQL files
Auto-commit, Commit, Roll BackShown once the tab has a connection: the tab's transaction controls.Commit and roll back changes
Read-onlyShown while the tab's connection is read-only.Read-only connections
The connection, at the rightThe connection this tab runs on. Click it to choose another.Choose a tab's connection and database
The database, beside itThe database of the server the tab runs in. Click it to choose another.Choose a tab's connection and database

Each button's tooltip gives its full name and its shortcut, and when a button is disabled, why. In a narrow window the buttons keep their icons and drop their labels.

The left edge of the bar is amber for a Testing or Staging connection and red for Production.

Write SQL

As you type, Querlyn colors the SQL, suggests what can come next, and underlines what looks wrong.

Run it

Put the cursor in a statement and press ⌘↩ on macOS or Ctrl+Enter on Windows and Linux. Querlyn runs that one statement and briefly highlights it, so you can see what ran.

SELECT id, name, city
FROM customers
WHERE city = 'London'
ORDER BY name;

The rows appear in the results pane under the editor.

Keep it

Press ⌘S on macOS or Ctrl+S on Windows and Linux to save the tab. A tab is kept either as a saved query inside Querlyn or as a .sql file on disk.

Note: On a connection whose environment is Production, Querlyn may ask before it runs a statement. Stay safe on production explains when.

Help for Querlyn 0.1.0. All help topics