Cassandra Batch

In Cassandra BATCH is used to execute multiple modification statements (insert, update, delete) simultaneously. It is very useful when you have to update some column as well as delete some of the existing.

Syntax:

Example:

Let's take an example to demonstrate BATCH command. Here, we have a table named "student" with columns (student_id, student_fees student_name,), having the following data.

Cassandra Batch 1

In this example, we will perform the BATCH (Insert, Update and Delete) operations:

  • Insert a new row with the following details (4, 4000, Sonoo).
  • Update the student_fees of student with row id 3 to 8000.
  • Delete student_fees of the employee with row id 2.
Cassandra Batch 2

Now the BATCH is applied. You can verify it by using SELECT command.

Cassandra Batch 3

Here, you can see that the table is completely modified by the above commands.


Next TopicCQL create data




Latest Courses