Documentation — Commands reference

update

Changes values in existing rows.

Syntax

update TABLE_NAME set COL1 = VAL1 [, COL2 = VAL2 ...] where CONDITION;

You need the UPDATE privilege. The table must be deployed and not locked, and the cluster must not be locked.

Restrictions

  • You cannot update a column of the hash key (Column 'x' is part of hash key. You cannot modify it.): it would move the row to another partition. Delete the row and insert it again with the new key.
  • A column cannot appear twice in the set clause.
  • A sub-query in the where runs on each data broker with its own data. The result depends on your design (see delete and A star model).
  • The usual restrictions of MariaDB apply: a foreign key with restrict may refuse the change.

How it runs

SynSQL first finds the rows that match the condition, then updates each of them by its hash key on all the copies. On a big table, a condition that matches many rows takes time: the command answers when it is over, and the number of updated rows is in the answer.

Wide tables

The same rows-then-key path is used for wide tables, chunk by chunk. A condition with or on columns of distant chunks costs more.

← truncate