CQL DML: INSERT statement
Learn the syntax, usage, and best practices for performing DML operation to INSERT data in Apache Cassandra tables effectively.
We'll cover the following...
In this lesson we'll focus on the Data Manipulation Language (DML) operations supported by Apache Cassandra.
Cassandra UPSERT operations
Cassandra performs UPSERTs, i.e., it treats inserts and updates synonymously. If the row with the primary key already exists in the table, INSERT update it. If the row with the primary key does not exist in the table, UPDATE insert it.
Each Cassandra column has a timestamp of when the data was last written. An optional TimeToLive value can also be set for the automatic expiration of the column’s data.
CQL allows both INSERT and UPDATE statements to specify these parameters.
TIMESTAMP for column value
By default, Cassandra sets the coordinator node’s current time as the write-time/timestamp for the operation. However, the user may specifically provide the value in the INSERT or UPDATE statement with the USING keyword. The value must be expressed in microseconds since the ...