Cassandra : Update gc_grace_seconds for keyspace

Viewed 131

Is it possible to update gc_grace_seconds for all the tables in a keyspace? Or should it had to be done per folder

1 Answers

There is no built-in command to change table options for all tables in the keyspace, but it's easy to implement using the bash + cqlsh. Something like this (replace keyspace_name and new_value with actual parameters):

cqlsh -e 'DESCRIBE FULL SCHEMA;'|grep -e '^CREATE TABLE keyspace_name'|\
   sed -e 's|^CREATE TABLE \(.*\) (|ALTER TABLE \1 WITH gc_grace_seconds = new_value; |'|\
   tee schema-changes.cql
cqlsh -f schema-changes.cql
Related