Help › Stay safe
See a change before you commit it
Dry-run an UPDATE or DELETE to see how many rows change and how, commit or roll it back, and write the inverse statements of a change later.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A dry run runs one UPDATE or DELETE without committing it, shows
how many rows it changes and each row before and after, and waits for you
to Commit or Roll Back. After a commit, Revert This Change
writes the statements that put the rows back, for you to review and run.
Dry-run a statement
- Put the cursor in the statement, or select it.
- Choose Dry Run in the bar above the editor, press ⇧⌘D on macOS or Ctrl+Shift+D on Windows and Linux, or choose .
Querlyn runs the statement inside a transaction, reads the rows it changes before and after by their key, and stops before the commit. The results pane opens on Dry Run:
- 412 rows will change in public.products (or will be deleted from), with the key Querlyn follows the rows by.
- The rows. For an
UPDATE: the key, and every column that changes, as the old value struck through and the new one after it. For aDELETE: the whole rows. They come 100 to a page; and , the arrows beside the row count, and ⇟ on macOS or PageDown on Windows and Linux and ⇞ on macOS or PageUp on Windows and Linux step through them. - Notes on what the dry run cannot show (see below).
UPDATE products
SET price = round(price * 1.04, 2)
WHERE supplier_id = 17
A dry run is not recorded in the query history: running it again from there would run the statement for real.
Commit or roll back
While the change waits, nothing is committed and the rows stay locked: other sessions that want to change them wait. Decide soon.
| Button | What it does |
|---|---|
| Commit | Commits the change. , or the tab's own ⇧⌘K on macOS or Ctrl+Shift+K on Windows and Linux. |
| Roll Back | Undoes it: the table is as it was. , or ⇧⌘⌫ on macOS or Ctrl+Shift+Backspace on Windows and Linux. |
The tab shows its transaction as open, and the lock alerts apply to it like to any open transaction: you see when others wait for it. Nothing else runs in the tab until you decide.
If your tab already has a transaction open, the dry run waits at a savepoint inside it. Keep Change then adds the change to your transaction (it is committed or rolled back with it), and Roll Back undoes only the dry run, keeping what you did before it.
A dry run is never committed by itself:
- Closing the tab rolls it back, without asking.
- Losing the connection rolls it back.
- Quitting asks first, as with any open transaction.
Dry run first
On a connection that asks before destructive statements (Production, and
by default Testing and Staging), the question before an UPDATE or
DELETE has a third button, Dry Run First. It runs nothing: the
statement is dry-run instead, and you decide from what you see.
When Querlyn refuses a dry run
Querlyn runs nothing and says why when it cannot be sure which rows the statement changes:
- It is not one
UPDATEorDELETE: a script, anINSERT, aMERGE. - It reads other tables to decide:
UPDATE … FROM,DELETE … USING, a join, several tables, a statement starting withWITH. - It has
LIMIT,TOP,FETCHorORDER BY, orIGNORE,OR REPLACEorOR IGNORE. - The table has no primary key and no unique key over columns that cannot
be
NULL, or theUPDATEchanges every such key. - The statement has query parameters. Write the values into it.
- The database commits each statement on its own (ClickHouse, Snowflake, Cassandra) or has no savepoints to undo with (BigQuery), or is not queried in SQL (MongoDB, Cassandra), or the table cannot roll back (a MySQL or MariaDB table on a storage engine without transactions, such as MyISAM).
- The connection is read-only, or its tab has a failed transaction, or an open transaction on a database without savepoints (DuckDB, Redshift).
The Dry Run button is disabled for a statement that is not an UPDATE
or DELETE, and its tooltip says why.
What a dry run cannot show
- Other tables. The counts and rows are of the statement's table only.
What its triggers change, and the rows that foreign keys delete or
change with it (
ON DELETE CASCADE), are not shown. Roll Back undoes those too. - Very large changes. Querlyn keeps up to 10,000 rows (and 16 MB) of each side, counts the rest, and says so. Such a change cannot be reverted from the journal.
- Counts that disagree. When the server reports another number of changed rows than the condition matched, the view says so.
Warning: Rolling back does not undo everything a statement can do: sequences stay advanced, and what a trigger or function did outside the database is not undone.
Revert a change
When you commit a dry run on a connection that keeps an undo journal, the view offers Revert This Change… ().
- Querlyn reads the rows as they are now and compares them with what your change left.
- It writes the inverse statements into a new query tab: an
UPDATEsetting the old values back for an update, anINSERTof each deleted row. A row that changed since, is gone, or exists again is left out, commented, with the reason, so the script never overwrites someone else's later change unseen. - Read the script, then run it yourself. Querlyn never runs it.
The undo journal
The undo journal keeps, on this computer only, the rows each committed dry run changed, before and after: lists a connection's changes, newest first, with when, what and how many rows. Select one and choose Revert… () for its inverse statements.
- It keeps the last 50 changes per connection, 200 in all, each for 30 days.
- deletes a connection's changes after asking. The database is not touched.
- It is never synced, and it holds no passwords. It does hold row data, so treat it like the database's own data.
Undo journal in the connection dialog chooses whether a connection keeps one: Keep or Off. A Production connection starts with Off, because the journal keeps rows where the query history keeps only metadata; the others start with Keep. The choice is this computer's and is not synced with the connection. The dialog shows it only for engines that can dry-run.
Help for Querlyn 0.1.0. All help topics