Cassandra Primary Key allows repetition

I tried to insert two records with all the same values ​​in the primary key in the Cassandra table, and the insertion was successful. I am new to Cassandra and think that Primary Keys in Cassandra do not allow repeated insertion. This is not correct? The following are the columns in my primary key

PRIMARY KEY((customer_id,source_id),status_code,create_timestamp,modified_timestamp)

The following is how I inserted it

insert into testkeyspace.customers 
(customer_id, source_id, status_code,
create_timestamp, modified_timestamp)
value ('123e4567-e89b-12d3-a456-426655440000 ',
1122334455, 0, toTimestamp(now()), toTimestamp(now()));

You are using toTimestamp(now()) for the 2 clustering columns in the primary key, so the 2 inserted records are unlikely to have exactly the same value for these columns, that is, the two records are not duplicates. < p>

Look at this answer to a similar question

I tried to insert two records with all the same values ​​in the primary key in the Cassandra table, and Insertion is successful. I am new to Cassandra and think that Primary Keys in Cassandra are not allowed to be inserted repeatedly. Is this incorrect? The following are the columns in my primary key

PRIMARY KEY((customer_id,source_id),status_code,create_timestamp,modified_timestamp)

The following is how I inserted it

insert into testkeyspace.customers 
(customer_id, source_id, status_code,
create_timestamp, modified_timestamp)
value ('123e4567-e89b-12d3-a456-426655440000 ',
1122334455, 0, toTimestamp(now()), toTimestamp(now()));

You are checking the 2 in the primary key Clustering columns use toTimestamp(now()), so 2 inserted records are unlikely to have exactly the same value for these columns, that is, the two records are not repeated.

Look at this answer to a similar question

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 261 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.