...

/

CQL DML: UPDATE statement

CQL DML: UPDATE statement

Learn the syntax, usage, and best practices for performing DML operations to UPDATE data in Apache Cassandra tables effectively.

We'll cover the following...

In this lesson, we will focus on the Data Manipulation Language (DML) UPDATE operations supported by Apache Cassandra.

The UPDATE statement

The UPDATE statement is used to write data in one or more columns of a given row. To identify the row for updation, values for all primary key columns for the table must be specified in the WHERE clause. Values of primary key columns cannot be updated. Values for one or more non-primary key columns are assigned using the SET keyword. If the row is non-existent, it is created. Otherwise, it is updated with the data provided. It cannot be known if the UPDATE statement resulted in an insert or an update.

Press + to interact
UPDATE table_name 
[ USING [TIMESTAMP timestamp_value] ('AND')* [TTL ttl_value] ]
SET
column_name = column_value ( ',' column_name = column_value )*
WHERE PK_column_name = PK_column_value ('AND' PK_column_name = PK_column_value )*
[ IF EXISTS | (IF condition (AND condition)*) ]
;

Please refer to syntax conventions for CQL syntax notation details.

For example, the ...