Skip to content

Edit data

Data changes need a saved session with Allow write (write mode in tabs, migration target) and a direct connection (not behind ProxySQL). See Write flags of a session.

The Write mode button sits in the header of a table tab, only when the session has Allow write. It is per tab: other tabs on the same connection stay read-only. A session with Production first asks Write mode on a production server (Turn on write mode).

Write mode does not lift READ ONLY from the session. It lets the tab prepare changes; each change switches the session to read-write only for its own statements and back. The console prints Write mode on (tab:…): every change is shown as exact SQL and sent only after approval; the session stays READ ONLY between changes.

Write mode on (click again) turns it off: pending grid changes are dropped and the session is checked (READ ONLY verified.). Closing the tab does the same. A reconnect ends write mode. Turning Allow write off in the session, or Production on without having confirmed it, ends write mode at the next review or send; nothing is sent (see Write flags of a session).

Write mode with one changed cell and one row marked for deletion

Action How
Change a cell Double-click it, type, Enter (Esc cancels); or edit the field in the record panel. Changed cells are marked.
Set NULL Record panel: NULL checkbox of the field.
New row Row: an empty row at the end; cells left untouched show DEFAULT and are not sent, so the column default applies.
Delete a row Select the row, Delete (again = unmark). Marked rows are crossed out.
Review Review SQL… builds the change; Discard drops everything pending (nothing was sent).

The bar shows the key used to find rows (key PRIMARY: id) and the number of pending changes. Paging, sorting and searching wait until the pending changes are sent or discarded (Apply or discard the pending changes first). Pending changes are lost when the window reloads.

Rows are found by the primary key, or else by the first unique index (by name) over plain columns (information_schema.STATISTICS, NON_UNIQUE = 0; indexes with functional parts are skipped). Grid editing is off, with the reason above the grid, for:

  • views (only base tables are edited in the grid);
  • tables without such a key (… has no primary key and no unique key over plain columns, so a row cannot be found exactly); the query editor in write mode can still change them.

Single rows cannot be changed or deleted when a key value is NULL or longer than the grid shows. Generated columns (VIRTUAL / STORED) are not editable and are left out of INSERT; cells cut in the grid (long text, long binary) cannot be edited.

Review of a grid change: one DELETE and one UPDATE in one transaction

Change Statement
Deleted row DELETE FROM `db`.`table` WHERE `id` = '96113'
Changed row UPDATE `db`.`table` SET `city` = 'Wrocław' WHERE `id` = '96116'
New row INSERT INTO `db`.`table` (`name`, `email`) VALUES ('…', '…')

Order: deletions, updates, new rows. Values go through the same literal rules as the search (hex for ', \, control and invisible characters); a binary key is matched as X'…'. DELETE has no LIMIT 1, so a key that matches two rows is detected. The key value is compared as text (id = '7'): correct for numbers, dates and text; a FLOAT/DOUBLE key may match nothing, which rolls the change back.

The dialog Approve change #n shows the title (db.table: n updated, n inserted, n deleted), the mode, Estimated rows with its source, and all statements (sent exactly as shown, copy icon). Send runs:

START TRANSACTION READ WRITE;
-- the statements, in the order shown
COMMIT;

Each statement must touch exactly one row (Rows matched for UPDATE, affected rows otherwise); any other count, or an error, sends ROLLBACK and The transaction was rolled back: nothing of it stays. After the change the session is checked (Applied in n ms (committed); READ ONLY verified.) and the page is read again.

In write mode the Query view has Run as change… (Run selection as change… with a selection). Run stays read-only. The statement is prepared like any change: the review shows it with Estimated rows: unknown, because KryoDesk does not parse SQL and EXPLAIN of a write fails in the read-only session (1792); the result shows the affected rows. Send runs:

SET SESSION TRANSACTION READ WRITE;
-- the statement (prepared statement protocol: exactly one)
SET SESSION TRANSACTION READ ONLY;

The statement commits on its own. The read-only keyword refusals (CALL, BEGIN, …) do not apply here. The session check follows as after any statement.

Tools in the context menu of a table or database. CHECK is read-only; the other tools turn write mode on for their dialog only (production asks first) and off when it closes.

Tool Statement Notes in the review
Check table / Check all tables CHECK TABLE `db`.`t` per table Read-only; results in one grid.
Analyze / Optimize / Repair table… (and … all tables…) ANALYZE TABLE / OPTIMIZE TABLE / REPAIR TABLE, one statement per base table OPTIMIZE rebuilds InnoDB tables (a copy on disk, metadata lock while it runs); REPAIR works on MyISAM, Aria, ARCHIVE and CSV only. Results in a grid.
Truncate table… TRUNCATE TABLE `db`.`t` Type the table name. Commits at once, cannot be rolled back, resets AUTO_INCREMENT, fails when a foreign key points at the table.
Drop table… / Drop view… DROP TABLE `db`.`t` / DROP VIEW Type the name.
Drop database… DROP DATABASE `db` Type the name; procedures, functions, events and triggers go too. A system schema gets a warning.

Check all tables and the other database tools use the tables of an expanded database (expand the database first). Names are checked against information_schema before the statement is built. Row estimates come from information_schema.TABLES.TABLE_ROWS. These statements run with a client limit of 1 hour; on MariaDB max_statement_time = 0 is set first. A wrong typed name does not use up the prepared change.

Scroll or pinch to zoom · drag to move · double-click to zoom · Esc or click outside to close