Cassandra – Batch
In tutorial, we will learn about the Batch command in Cassandra which allows us to write multiple DML statements in a single shot. DML statements include the Insert, Update, Delete commands.
DML statements:
INSERT
UPDATE
DELETE
Syntax:
BEGIN ( UNLOGGED | COUNTER ) BATCH USING TIMESTAMP timestamp dml_statement; dml_statement; ... APPLY BATCH;
Example:
BEGIN BATCH INSERT INTO users (user_id,first_name, second_name) VALUES ('1001', 'Cassandra', 'julie') UPDATE users SET city = 'Banglore' WHERE userID = '1020' DELETE first_name FROM users WHERE userID = '1234' APPLY BATCH;