Is it possible to create a table that has a default TTL for all rows that are inserted into it, or do you have to always remember to set the TTL when you do an insert/update?
Cant see anything on this in the documentation:
http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/create_table_r.html
From Cassandra doc : You can set a default TTL for an entire table by setting the table's default_time_to_live property. If you try to set a TTL for a specific column that is longer than the time defined by the table TTL, Apache Cassandra™ returns an error.
In Cassandra Both the INSERT and UPDATE commands support setting a time for data in a column to expire. It is used to set the time limit for a specific period of time. By USING TTL clause we can set the TTL value at the time of insertion. We can use TTL function to get the time remaining for a specific selected query.
You can't create a table in Cassandra without a primary key, But still if you want to save your data you can add an additional column to your table (let say "pk") with data type UUID.
The primary key is a column that is used to uniquely identify a row. Therefore,defining a primary key is mandatory while creating a table. A primary key is made of one or more columns of a table.
Yes it is possible to set TTL for the entire column family.
CREATE TABLE test_table (
# your table definition #
) WITH default_time_to_live = 10;
Inserted rows then disappear after 10 seconds.
I believe the work was done for it here:
https://issues.apache.org/jira/browse/CASSANDRA-3974
Here's a docs reference sent by Patrick McFadin of DataStax (@PatrickMcFadin):
http://docs.datastax.com/en/cql/3.1/cql/cql_reference/tabProp.html
Cheers,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With