Updating column's in Cassandra
Last Updated :
12 Jul, 2025
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 column, Drop a column, Rename existing column as shown here:
ALTER TABLE [keyspace_name.] table_name
[ALTER column_name TYPE cql_type]
[ADD (column_definition_list)]
[DROP column_list | COMPACT STORAGE ]
[RENAME column_name TO column_name]
[WITH table_properties];
Now, here if you want to change the column name which has a primary key. for example: In User_Data existing table if you want to change the column name from id to user_id then you can run Rename command.
CREATE TABLE app_data.user_data (
id UUID PRIMARY KEY,
address text,
name text
);
cassandra@cqlsh:app_data>
select * from User_Data;
id | address | name
----+---------+------
Now, to change the column name you can execute the following CQL query given below.
cassandra@cqlsh:app_data>
Alter table User_data RENAME id TO User_id;
Now, to verify the results whether column successfully changed or not then you can execute the following CQL query.
cassandra@cqlsh:app_data> describe User_data;
CREATE TABLE app_data.user_data (
user_id uuid PRIMARY KEY,
address text,
name text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL',
'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction =
{
'class': 'org.apache.cassandra
.db.compaction.SizeTieredCompactionStrategy',
'max_threshold': '32', 'min_threshold': '4'
}
AND compression =
{
'chunk_length_in_kb': '64',
'class': 'org.apache.cassandra
.io.compress.LZ4Compressor'
}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
Now, to see the output of the table, you can execute the following CQL query.
cassandra@cqlsh:app_data>
SELECT * FROM user_data;
user_id | address | name
---------+---------+------
(0 rows)
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
Update clause in Cassandra In this article, we will discuss how we can update the column in a table and how we can update multiple columns in a single row and how we can insert column value on the based some condition. Let's discuss one by one. Let's consider a table User_data which has User_id for uniquely identified rows, N
2 min read
Update clause in Cassandra In this article, we will discuss how we can update the column in a table and how we can update multiple columns in a single row and how we can insert column value on the based some condition. Let's discuss one by one. Let's consider a table User_data which has User_id for uniquely identified rows, N
2 min read
Updating a List in Cassandra 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 clus
2 min read
Updating a List in Cassandra 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 clus
2 min read