Help › Work with results

Edit rows in a result

Change cells, add, duplicate and delete rows in the results grid, review the SQL, apply the changes, and know how Querlyn identifies each row.

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

You can change data straight in the results grid. Nothing reaches the database while you edit: your changes are collected, you can read the SQL they amount to, and they are sent when you choose Apply.

When a result can be edited

The line above the grid says Editable and the table's name when the rows can be changed, or Read-only and the reason, for example "Read-only: results of joins are read-only". When the window is too narrow for the whole reason, rest the pointer on it to read it all.

A result is editable when all of this holds:

  • It comes straight from one table. SELECT … FROM one_table, with any WHERE and ORDER BY. A result of a join, a GROUP BY, a DISTINCT, a UNION, a view, a WITH query or a subquery is read-only.
  • Querlyn can tell the rows apart; see the next section.
  • The connection is not read-only, and the database supports it: every database except ClickHouse and Snowflake. MongoDB's documents are edited by their _id, keeping each value's type; see Edit MongoDB documents. On BigQuery only a table that declares a primary key can be edited; see Connect to Google BigQuery. On Cassandra a row is changed by its whole primary key and each change applies on its own, without a transaction; see Connect to Apache Cassandra.

Columns that the query computes, such as price * quantity, cannot be edited even in an editable result.

How Querlyn identifies a row

Each change becomes an UPDATE or DELETE for exactly one row, so Querlyn needs something that identifies the row. It uses, in this order:

  1. The table's primary key, when the result includes all its columns.
  2. Otherwise a unique constraint whose columns cannot be NULL, when the result includes them.
  3. Otherwise nothing: the result is read-only, and a warning above the grid says why. If the table has a primary key that your query left out, the warning tells you to add it to the select list.

For a table with no key at all, the warning has an Edit Without a Key… button (Command Palette › Results: Allow Editing Without a Key…). After a question, Querlyn then identifies each row by all of its values together.

Warning: Editing without a key is the unsafe way. Querlyn checks that every change touches exactly one row and refuses it otherwise, so a row that has an identical twin can never be changed this way. Prefer giving the table a key.

Whatever identifies the row, Querlyn checks after each statement that exactly one row was changed. If not, the change is not kept.

Change a cell

ToDo this
Start editingDouble-click the cell, press ↩ on macOS or F2 on Windows and Linux or F2 on macOS or Enter on Windows and Linux, or choose Edit in the bar above the grid.
Replace the valueSelect the cell and just start typing.
Keep the new value and move down↩ on macOS or Enter on Windows and Linux
Keep it and move right or left⇥ on macOS or Tab on Windows and Linux, ⇧⇥ on macOS or Shift+Tab on Windows and Linux
Keep it and move to the cell above or below↑ on macOS or Up on Windows and Linux, ↓ on macOS or Down on Windows and Linux
Keep it and stay on the cell⌘↩ on macOS or Ctrl+Enter on Windows and Linux
Keep it and apply all pending changes⌘S on macOS or Ctrl+S on Windows and Linux
Give up the edit⎋ on macOS or Esc on Windows and Linux
Set the cell to NULL⌘⌫ on macOS or Ctrl+Backspace on Windows and Linux on the cell. While editing: ⌘⌫ on macOS or Ctrl+Backspace on Windows and Linux, or NULL in the bar.

Clicking another cell also keeps the value. While a cell is being edited, the bar above the grid offers Expand, NULL and Cancel.

A masked cell opens for editing only once its value is shown; typing on it still replaces the value without showing it.

A changed cell is marked in the grid. It is not in the database yet.

While you type in a cell, the keys for moving and correcting are the ones of any text field. They are bindings like all others, so you can change them:

ToPress
Move by a character← on macOS or Left on Windows and Linux, → on macOS or Right on Windows and Linux
Move by a word⌥← on macOS or Ctrl+Left on Windows and Linux, ⌥→ on macOS or Ctrl+Right on Windows and Linux
Move to the start or end of the line⌘← on macOS or Home on Windows and Linux, ⌘→ on macOS or End on Windows and Linux
Move to the start or end of the value↖ on macOS or Ctrl+Home on Windows and Linux, ↘ on macOS or Ctrl+End on Windows and Linux
Select by a character⇧← on macOS or Shift+Left on Windows and Linux, ⇧→ on macOS or Shift+Right on Windows and Linux
Select by a word⌥⇧← on macOS or Ctrl+Shift+Left on Windows and Linux, ⌥⇧→ on macOS or Ctrl+Shift+Right on Windows and Linux
Select to the start or end of the line⇧⌘← on macOS or Shift+Home on Windows and Linux, ⇧⌘→ on macOS or Shift+End on Windows and Linux
Select everything⌘A on macOS or Ctrl+A on Windows and Linux
Delete a character backward or forward⌫ on macOS or Backspace on Windows and Linux, ⌦ on macOS or Delete on Windows and Linux
Delete the next word⌥⌦ on macOS or Ctrl+Delete on Windows and Linux
Delete the previous wordThe shortcut Help › Keyboard Shortcuts lists for Cell Editor: Delete Previous Word
Copy, cut, paste⌘C on macOS or Ctrl+C on Windows and Linux, ⌘X on macOS or Ctrl+X on Windows and Linux, ⌘V on macOS or Ctrl+V on Windows and Linux
Undo, redo⌘Z on macOS or Ctrl+Z on Windows and Linux, ⇧⌘Z on macOS or Ctrl+Y on Windows and Linux

Undo and redo here work on what you typed in the cell, not on changes you already kept.

What you can type

Querlyn checks what you type against the column's type before it accepts it: whole numbers must fit, decimals are kept exactly, dates and times must be valid, JSON must be well formed, and binary data is typed as hex. If the value does not fit, the cell stays open with the reason under it.

  • NULL and empty are different. A NULL cell shows NULL. Deleting everything in a text cell gives an empty text, not NULL. To get NULL, set it as in the table above; a column that does not allow NULL refuses it.
  • A yes/no value flips when you double-click it or press ↩ on macOS or F2 on Windows and Linux.
  • A column the database numbers itself (identity, auto-increment) cannot be changed in an existing row. In a new row you can type a value or leave it for the database to assign.
  • A column the database computes cannot be edited.

Edit a long value

Text with line breaks, values longer than 200 characters and longer JSON or binary values open in a larger editor over the cell. You can also open it yourself with ⇧↩ on macOS or Shift+Enter on Windows and Linux, or go on in it from a cell you are editing with ⇧↩ on macOS or Shift+Enter on Windows and Linux.

In the larger editor, ↩ on macOS or Enter on Windows and Linux adds a line. ⌘↩ on macOS or Ctrl+Enter on Windows and Linux or Keep keeps the value, ⎋ on macOS or Esc on Windows and Linux or Cancel gives it up, and Set NULL sets NULL.

In the larger editor, toPress
Go up or down a line↑ on macOS or Up on Windows and Linux, ↓ on macOS or Down on Windows and Linux
Extend the selection up or down a line⇧↑ on macOS or Shift+Up on Windows and Linux, ⇧↓ on macOS or Shift+Down on Windows and Linux
Move to the start or end of the value⌘↑ on macOS or Ctrl+Home on Windows and Linux, ⌘↓ on macOS or Ctrl+End on Windows and Linux

Add, duplicate and delete rows

ToDo this
Add an empty rowAdd Row in the bar, or ⌘N on macOS or Ctrl+N on Windows and Linux. Its cells show DEFAULT until you type: what you leave is filled in by the database.
Copy the selected rows as new rows⌘D on macOS or Ctrl+D on Windows and Linux (Command Palette › Results: Duplicate Rows). Key columns are left for the database to fill.
Delete the selected rowsDelete in the bar, or ⌥⌘⌫ on macOS or Ctrl+Shift+Delete on Windows and Linux. The rows are marked and are removed when you apply.

Review, revert and apply

While there are changes, a bar above the grid counts them and offers:

ButtonWhat it does
Preview SQLShows the statements Querlyn will run (Query › Preview SQL for Pending Changes). Hide SQL closes the preview.
RevertDrops every change (Query › Revert All Pending Changes). To drop only the changes in the selected cells, right-click and choose Revert Selected Changes (Command Palette › Results: Revert Selected Changes).
ApplySends the changes to the database (⌘S on macOS or Ctrl+S on Windows and Linux).

Warning: Apply changes the data in the database. With auto-commit on, the changes are committed at once. With auto-commit off, they become part of the tab's transaction and are kept only when you commit it.

What happens when you apply:

  • On a Production connection Querlyn first shows the statements and asks. On Testing and Staging it asks only when rows are deleted or edited without a key. Values of masked columns are shown as •••••••• in the statements; the real values are sent.
  • The changes are applied together. If the database rejects one, none is kept, the message says why, and the grid goes to the row in question.
  • If a row was changed or removed by someone else since you fetched it, its change is not applied and stays pending, while the other changes go through. The bar says how many were not applied.
  • A row you added shows what you typed. To see values the database filled in, and to edit that row again, run the query again.

Running again or closing with changes pending

If you run the tab's statement again, or close the tab, while changes are pending, Querlyn asks: Apply and Run (or Apply and Close), Discard and Run (or Discard and Close), or Cancel. Quitting and disconnecting ask whether to discard them.

What depends on the database

  • DuckDB and Amazon Redshift: rows cannot be edited while your own transaction is open in the tab; commit or roll back first.
  • Amazon Redshift: keys are not enforced, so a "key" may match several rows. Querlyn's check that one row changed protects you: such a change is undone.
  • Oracle Database: a DATE holds a time of day, so type it as YYYY-MM-DD HH:MM:SS.
  • Amazon Redshift: SUPER and VARBYTE values cannot be edited.

Sorting, filtering and copying use the values as they were fetched, not your pending changes.

Help for Querlyn 0.1.0. All help topics