Was this page helpful?
You're viewing documentation for an unstable version of ScyllaDB Enterprise. Switch to the latest stable version.
DELETE can be executed in a single statement by grouping them through a
batch_statement: BEGIN [ UNLOGGED | COUNTER ] BATCH : [ USING `update_parameter` ( AND `update_parameter` )* ] : `modification_statement` ( ';' `modification_statement` )* : APPLY BATCH modification_statement: `insert_statement` | `update_statement` | `delete_statement`
BEGIN BATCH INSERT INTO users (userid, password, name) VALUES ('user2', 'ch@ngem3b', 'second user'); UPDATE users SET password = 'ps22dhds' WHERE userid = 'user3'; INSERT INTO users (userid, password) VALUES ('user4', 'ch@ngem3c'); DELETE name FROM users WHERE userid = 'user1'; APPLY BATCH;
BATCH statement group multiple modification statements (insertions/updates and deletions) into a single
statement. It serves several purposes:
It saves network round-trips between the client and the server (and sometimes between the server coordinator and the replicas) when batching multiple updates.
All updates in a
BATCH belonging to a given partition key are performed atomically.
By default, all operations in the batch are performed as logged, to ensure all mutations eventually complete (or none will). See the notes on UNLOGGED batches for more details.
BATCH statements may only contain
DELETE statements (not other batches, for instance).
Batches are not a full analogue for SQL transactions.
If a timestamp is not specified for each operation, then all operations will be applied with the same timestamp
(either one generated automatically, or the timestamp provided at the batch level). Due to Scylla’s conflict
resolution procedure in the case of timestamp ties, operations may be applied in an order that is different from the order they are listed in the
BATCH statement. To force a
particular operation ordering, you must specify per-operation timestamps.
A LOGGED batch to a single partition will be converted to an UNLOGGED batch as an optimization.
BATCH supports the
TIMESTAMP option with the same semantics as the TIMESTAMP parameter in
For more information on the
update_parameter refer to the UPDATE section.
By default, Scylla uses a batch log to ensure all operations in a batch eventually complete or none will (note, however, that operations are only isolated within a single partition).
There is a performance penalty for batch atomicity when a batch spans multiple partitions. If you do not want to incur
this penalty, you can tell Scylla to skip the batchlog with the
UNLOGGED option. If the
UNLOGGED option is
used, a failed batch might leave the batch only partly applied.
COUNTER option for batched counter updates. Unlike other
updates in Scylla, counter updates are not idempotent.
© 2016, The Apache Software Foundation.
Apache®, Apache Cassandra®, Cassandra®, the Apache feather logo and the Apache Cassandra® Eye logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.