In Cassandra, there is no concept of a primary key, whether it exists or not, it is only cells that exist with a specific primary key.
So, for regular column families (i.e. non-counter) you can insert or update (they are semantically identical) if anything was previously inserted with this primary key.
Regarding counter tables, CQL requires you to use update , not insert , so that it is clear that it increments rather than sets a value. You cannot set the counter value in Cassandra, only inc / dec. If there was no previous counter, it is assumed that it has a value of 0. Thus, you can run
update count1 set c1 = c1 + 1 where id = 2;
and the counter will have a value of 1:
select * from count1; id | c1
source share