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 (⌘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 .
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
| Control | What it does | Read more |
|---|---|---|
| Run | Runs the statement the cursor is in. Reads Running… while a query runs. | Run statements and scripts |
| Run Selection | Runs the selected SQL, one statement after another. | Run statements and scripts |
| Cancel | Stops the running query. | Run statements and scripts |
| Dry Run | Runs 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 Analyze | Show how the database would run, or did run, the statement at the cursor. | See a query's execution plan |
| Format | Lays 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 Back | Shown once the tab has a connection: the tab's transaction controls. | Commit and roll back changes |
| Read-only | Shown while the tab's connection is read-only. | Read-only connections |
| The connection, at the right | The connection this tab runs on. Click it to choose another. | Choose a tab's connection and database |
| The database, beside it | The 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.
- Edit text in the SQL editor: the keys, comments, indenting.
- Complete SQL as you type
- Read the editor's underlines
- Format SQL
- Insert snippets
- Find and replace
- Edit in several places at once
- Fold parts of a query
- Refactor a query
- Use Vim keys
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.
- Run statements and scripts
- Run a query with parameters
- Commit and roll back changes
- See a change before you commit it
- Run a query on several connections
- Work with results
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