Help › Run queries
Commit and roll back changes
See a tab's transaction state, turn auto-commit on and off, begin, commit and roll back, and what happens to an open transaction when you close a tab.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A transaction lets you change data and then decide: keep the changes (commit) or undo them (roll back). Querlyn always shows whether a tab has a transaction open, and never closes one behind your back.
The four states
Each query tab's session is in one of four states. The control in the bar above the editor shows it, and the tab is marked TX while a transaction is open.
| The control reads | Meaning |
|---|---|
| Auto-commit | Each statement is committed as soon as it succeeds. There is nothing to commit or roll back. |
| Manual commit | Auto-commit is off and no transaction is open. The next statement you run opens one (on Oracle, the next statement that changes data). |
| Transaction open | Changes are waiting. Other sessions do not see them until you commit. |
| Transaction failed — roll back | A statement failed inside the transaction, and the database accepts nothing more until you roll back. The tab's mark reads TX ✗. |
While auto-commit is off, or a transaction is open, the bar also shows Commit and Roll Back. The status bar repeats the state.
Commit and roll back
| To | Do this |
|---|---|
| Keep the changes | Commit, or ⇧⌘K on macOS or Ctrl+Shift+K on Windows and Linux () |
| Undo the changes | Roll Back, or ⇧⌘⌫ on macOS or Ctrl+Shift+Backspace on Windows and Linux () |
A message confirms it: "Transaction committed." or "Transaction rolled back."
You can also type COMMIT and ROLLBACK as statements and run them.
Querlyn follows what the database reports, so the state shown is the real
one either way.
Work with auto-commit off
With auto-commit off, everything a tab changes stays in a transaction until you commit. This is how tabs on a Production connection start.
To change it, click the Auto-commit / Manual commit control, or press ⇧⌘A on macOS or Ctrl+Shift+A on Windows and Linux ().
- The choice applies to every tab of that connection, and is saved with the connection.
- It cannot be changed while one of the connection's tabs has a transaction open; commit or roll back first.
- Changing a connection's environment sets it back to what the new environment starts with.
Open one transaction with auto-commit on
To group a few statements without turning auto-commit off, choose (⇧⌘B on macOS or Ctrl+Shift+B on Windows and Linux). The tab shows Transaction open until you commit or roll back; after that it is back to Auto-commit.
Typing BEGIN and running it does the same.
When the transaction has failed
On PostgreSQL and some other databases, an error inside a transaction spoils the whole transaction. The tab shows Transaction failed — roll back, and Querlyn does not send further statements: it says "The transaction failed. Roll it back … before running more statements." Choose Roll Back, then start again.
Not every database works this way. Oracle and MySQL, for example, undo only the statement that failed, and the transaction stays open.
Closing with a transaction open
If you close a tab, disconnect, or quit while a transaction is open, Querlyn asks first:
| Button | What it does |
|---|---|
| Commit and Close (or … and Quit, … and Disconnect) | Commits, then closes. On a Production connection this button is red. |
| Roll Back | Rolls back, then closes. |
| Cancel | Keeps everything open. |
If committing fails, nothing is closed.
A dry run that waits in a transaction of its own is the exception: closing its tab rolls it back without asking, because nothing of it was committed.
Things that depend on the database
- ClickHouse has no transactions, and Snowflake cannot keep one open between runs. Their tabs always show Auto-commit; see Connect to ClickHouse and Connect to Snowflake.
- BigQuery keeps a transaction in a BigQuery session of the tab. It
holds inserts, updates, deletes and merges;
CREATE,ALTERandDROPof permanent tables run only with auto-commit on. See Connect to Google BigQuery. - MongoDB has transactions on a replica set or a sharded cluster, not on a single server, whose tabs always show Auto-commit. Reads and writes of documents join the transaction; creating or dropping a collection or an index runs outside it, and may wait for it to end. The server rolls back a transaction left open longer than its limit, 60 seconds by default: while one is open, the bar above the editor counts down (Commit within 40 s), and choosing it commits. See Connect to MongoDB.
- Cassandra has no transactions: every statement takes effect when it
runs, and tabs always show Auto-commit. A batch applies its
statements together, and
IFconditions make a write to one partition conditional. See Connect to Apache Cassandra. - MySQL, MariaDB and Oracle commit the open transaction when you run a
statement that changes the structure, such as
CREATE TABLE. Such a change cannot be rolled back. On MySQL and MariaDB Querlyn adds a warning to Messages when that happened. - DuckDB and Amazon Redshift have no savepoints, so editing rows in the results and Explain Analyze are refused while your own transaction is open.
Long-open transactions
A transaction that stays open holds locks that other sessions may be waiting for. Querlyn tells you when that happens, and reminds you of a transaction left open; see Lock waits and timeouts.
Help for Querlyn 0.1.0. All help topics