CQL for Cassandra 2.0

Determining the date/time of a write

Using the WRITETIME function in a SELECT statement returns the date/time in microseconds that the column was written to the database. This procedure continues the example from the previous procedure and calls the WRITETIME function to retrieve the date/time of the writes to the columns.

Procedure

  1. Insert more data into the table.
    INSERT INTO excelsior.clicks (
      userid, url, date, name)
      VALUES (
        cfd66ccc-d857-4e90-b1e5-df98a3d40cd6,
        'http://google.com',
        '2013-10-11', 'Bob'
    );
  2. Retrieve the date/time that the value Mary was written to the name column of the apache.org data. Use the WRITELINE function in a SELECT statement, followed by the name of a column in parentheses:
    SELECT WRITETIME (name) FROM excelsior.clicks
      WHERE url = 'http://apache.org' ALLOW FILTERING;
    The writetime output in microseconds converts to Sun, 14 Jul 2013 21:57:58 GMT or to 2:57 pm Pacific time.
    writetime(name)
    ------------------
    1373839078327001
  3. Retrieve the date/time of the last write to the date column for google.com data.
    SELECT WRITETIME (date) FROM excelsior.clicks
      WHERE url = 'http://google.com' ALLOW FILTERING;
    The writetime output in microseconds converts to Sun, 14 Jul 2013 22:03:15 GMT or 3:03 pm Pacific time.
    writetime(date)
    ------------------
    1373839395324001
                        
    (1 rows)
Show/hide