Help › Run queries
Run statements and scripts
Run the statement at the cursor, a selection or a whole script, see how Querlyn finds a statement's ends, stop a query, and read errors.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A query tab can hold many statements. You choose how much of it runs.
Run the statement at the cursor
Put the cursor anywhere in a statement and press ⌘↩ on macOS or Ctrl+Enter on Windows and Linux (), or choose Run in the bar above the editor.
Only that statement runs. It is highlighted for a moment, so you can see what was sent. A selection makes no difference to Run: it always runs the statement the cursor is in.
Run a selection or a whole script
Select the SQL to run and press ⇧⌘↩ on macOS or Ctrl+Shift+Enter on Windows and Linux (), or choose Run Selection.
To run everything in the tab, select it all first (⌘A on macOS or Ctrl+A on Windows and Linux), then run the selection.
When the selection holds several statements:
- They run one after another, in order, on the tab's session.
- Each statement that returns rows gets a result of its own, on a tab in the results pane: Result 1, Result 2.
- If a statement fails, the run stops there. The statements after it do not run.
- Only the last result can load more rows as you scroll. Earlier results show their first 1,000 rows and say truncated.
On SQL Server, each batch between GO lines is sent as one request. On
Snowflake, the whole run is one request, and its results arrive together.
On BigQuery, a run of several statements is one script, and their results
arrive in order; before it runs, Messages says how many bytes it will
read (see Connect to Google BigQuery).
With auto-commit on, each statement that succeeded before a failure stays committed. To make a script all or nothing, run it in a transaction; see Commit and roll back changes.
Where a statement begins and ends
Querlyn splits a tab into statements the way the database does: at the semicolons, not at blank lines.
SELECT count(*) FROM orders;
SELECT count(*) FROM customers;
- A semicolon inside a string, a comment, or a function body between dollar quotes does not end a statement.
- A
BEGIN … ENDblock is one statement. - On SQL Server,
GOon a line of its own ends a batch. On MySQL and MariaDB,DELIMITERchanges the separator. On Oracle, a/on a line of its own ends a PL/SQL block. - Two statements with no semicolon between them are one statement, and the database will reject it.
When the cursor is between two statements, Run takes the one before it if the cursor is on that statement's last line or the line right after, and otherwise the one after it if the cursor is on its first line or the line right before. With blank lines on both sides, nothing runs and Querlyn says "No statement at the cursor."
While a query runs
Run reads Running…, and the line above the results counts the time and the rows so far. A tab runs one thing at a time: to run something else meanwhile, use another tab. Once the first rows of a large result are there, the query is no longer running: the line says how long they took, and Run is ready again (see Large results).
Stop a query
Press ⌘. on macOS or Ctrl+. on Windows and Linux (), or choose Cancel. Querlyn asks the database to stop the statement; the run ends as cancelled, and the rows that had already arrived stay.
Cancelling stops the statement that is running. Statements of the same run that had already finished stay as they are.
Read what happened
The line above the results sums up the run, for example "1,000 rows · 35 ms · more available".
The Messages tab of the results pane lists, for each run:
- how many rows each statement changed, and how long it took;
- what the server reported while it ran (notices, warnings,
PRINToutput); - an error, with where it is in your tab, such as "line 3, column 8".
When a run fails, Messages is shown at once.
What can come between you and a run
| Before running, Querlyn may | When |
|---|---|
| Ask for values | The statement has parameters. See Run a query with parameters. |
| Ask you to confirm | The connection's environment calls for it. See Confirm risky statements. |
| Refuse | The connection is read-only and the statement would change data. See Read-only connections. |
| Ask what to do with row changes | The results have edits that are not applied yet. See Edit rows in a result. |
| Refuse until you roll back | The tab's transaction has failed. |
| Refuse until you commit or roll back | A dry run waits in the tab, or a run on several connections left changes waiting for Commit All or Roll Back All. |
| Ask about a lock | The statement would make other sessions wait on a large table. See Migration lock warnings. |
Help for Querlyn 0.1.0. All help topics