Updating data

So now let's update one of our PENDING orders to a status of PICKED, and give it a value for shipping weight. We can start by updating our shipping_weight_kg for order fcb15fc2-feaa-4ba9-a3c6-899d1107cce9, and we'll assume that it is 1.4 kilograms. This can be done in two different ways. Updates and inserts are treated the same in Cassandra, so we could actually update our row with the INSERT statement:

INSERT INTO order_status (status,order_id,shipping_weight_kg)  VALUES ('PENDING',fcb15fc2-feaa-4ba9-a3c6-899d1107cce9,1.4);

Or, we can also use the UPDATE statement that we know from SQL:

UPDATE order_status SET shipping_weight_kg=1.4WHERE status='PENDING'AND order_id=fcb15fc2-feaa-4ba9-a3c6-899d1107cce9;

Either way, we can then ...

Get Mastering Apache Cassandra 3.x - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.