0
votes

i have a table similar to below where name is the primary key

name    pay creation date   update date
mike    1000    3/1/2020    3/1/2020

i need to insert multiple records to the table and if record already exists i need to update the row. The challenge is create date. Create date should not be updated, it is just needs to be inserted. i am using simple update query like

update table_name set pay=2000,creation date=sys date,update date=sysdate where name='mike';

1
Your question isn't completely clear - can you write what you want to get at the end? - Alex Ott

1 Answers

1
votes

In Cassandra there is no difference between INSERT and UPDATE (if you're not using lightweight transactions) - everything is UPSERT. This means, that if you do INSERT and row exists, then data will be updated, and if you do UPDATE and row doesn't exist, it will be created. So, for your problem - you can just perform INSERTs without worrying about checking if row exists, and doing UPDATE instead of INSERT.