April 2017
Beginner to intermediate
360 pages
9h 35m
English
Typically, write timestamps are assigned to data automatically by Cassandra, reflecting the time at which the cluster initially receives the request. However, CQL gives us a mechanism to override the default timestamp and instead choose our own.
To demonstrate, let's say we want to add a location value to the bob user record at a specific timestamp: December 14, 2016 at 10.33.24 UTC. In order to do this, we can use the USING TIMESTAMP clause in our UPDATE query:
UPDATE "users" USING TIMESTAMP 1481711604904000 SET "location" = 'Austin, TX' WHERE "username" = 'bob';
Reading bob's user record back, we can see that it now has the location we specified:
Now let's issue another update to bob's location using a TIMESTAMP ...
Read now
Unlock full access