Updating a List in Cassandra
Last Updated :
12 Jul, 2025
In
Cassandra list is a
Collection Data Type. In this article, we will discuss how we can update a list in different ways such that we can add elements in the list at any position where we want. we can also append a list.
Let's discuss one by one.
Consider cluster1 is a keyspace.
CREATE KEYSPACE cluster1
WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 1};
Now, here we are going to create a table first. let's have a look.
Create Table Food_App
(
Cafe_id Int Primary Key,
Order_Date Date,
Order_status Text,
Cafe_items list<text>
);
Now, we are going to insert some data into the Food_App table.
Let's have a look.
INSERT INTO Food_App (Cafe_id, Order_Date, Order_status, Cafe_items)
VALUES (8045, '2019-02-13', 'Available', {'Banana', 'Mango', 'Apple'});
INSERT INTO Food_App (Cafe_id, Order_Date, Order_status, Cafe_items)
VALUES (8046, '2019-02-15', 'Not Available', {'guava', 'juice', 'milk'});
INSERT INTO Food_App (Cafe_id, Order_Date, Order_status, Cafe_items)
VALUES (8047, '2019-02-18', 'Available', {'grapes', 'papaya', 'mix fruit'});
Now, let's see the output.
select *
from Food_App;
Output:
Updating a list:
UPDATE Food_App
SET Cafe_items = ['fruits', 'lemon tea', 'green tea']
Where Cafe_id = 8045;
Now, let's see the output.
select *
from Food_App;
Output:

To append an element to the list, switch the order of the new element data and the list name:
UPDATE Food_App
SET Cafe_items = Cafe_items + ['bread']
WHERE Cafe_id = 8045;
Now, let's see the output.
select *
from Food_App;
Output:

To prepend an element to the list, enclose it in square brackets and use the addition (+) operator:
UPDATE Food_App
SET Cafe_items = ['bread']+Cafe_items
WHERE Cafe_id = 8046;
Now, let's see the output.
select *
from Food_App;
Output:
Similar Reads
Updating Set in Cassandra In this article, we will discuss how we can update set Collection Data Type in different ways also we will discuss how we can insert rows by using the UPDATE clause and if we donât want any set elements then we can also remove using UPDATE clause with (â) operator. First, we will create table Food_m
2 min read
Updating Set in Cassandra In this article, we will discuss how we can update set Collection Data Type in different ways also we will discuss how we can insert rows by using the UPDATE clause and if we donât want any set elements then we can also remove using UPDATE clause with (â) operator. First, we will create table Food_m
2 min read
Updating column's in Cassandra In this article, we will discuss how we can update the existing columns, how we can add a new column or drop a column in Cassandra, etc. Updating a column In Cassandra, to modify a column by executing an ALTER statement. Using ALTER table statement You can change the type of a column, Add a new colu
2 min read
Updating column's in Cassandra In this article, we will discuss how we can update the existing columns, how we can add a new column or drop a column in Cassandra, etc. Updating a column In Cassandra, to modify a column by executing an ALTER statement. Using ALTER table statement You can change the type of a column, Add a new colu
2 min read
Batch statement in Cassandra In this article, we will discuss the BATCH statement, good and misuse of BATCH statement and how we can use the BATCH statement in single and multiple partitions in Cassandra which is supported by Cassandra Query Language (CQL). let's discuss one by one. We can use the BATCH statement in single and
2 min read
Batch statement in Cassandra In this article, we will discuss the BATCH statement, good and misuse of BATCH statement and how we can use the BATCH statement in single and multiple partitions in Cassandra which is supported by Cassandra Query Language (CQL). let's discuss one by one. We can use the BATCH statement in single and
2 min read