Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get cassandra tables creation date

How can I get the creation date and time of a cassandra table?

I tried to use cqlsh DESC TABLE but there is no information about the creation time stamp...


1 Answers

Depending on your version of Cassandra, you can check the schema tables. Each table gets a unique ID when it is created, and that ID gets written to the schema tables. If you query the WRITETIME of that ID, it should give you a UNIX timestamp (in microseconds) of when it was created.

Cassandra 2.2.x and down:

> SELECT keyspace_name, columnfamily_name, writetime(cf_id) 
    FROM system.schema_columnfamilies 
    WHERE keyspace_name='stackoverflow' AND columnfamily_name='book';

 keyspace_name | columnfamily_name | writetime(cf_id)
---------------+-------------------+------------------
 stackoverflow |              book | 1446047871412000

(1 rows)

Cassandra 3.0 and up:

> SELECT keyspace_name, table_name, writetime(id) 
    FROM system_schema.tables 
    WHERE keyspace_name='stackoverflow' AND table_name='book';

 keyspace_name | table_name | writetime(id)
---------------+------------+------------------
 stackoverflow |       book | 1442339779097000

(1 rows)
like image 171
Aaron Avatar answered Apr 03 '26 15:04

Aaron