Anil Kapoor
Anil Kapoor

Reputation: 784

DESC counters in Cassandra similar to KEYSPACE & TABLES?

Is this possible in Cassandra CQLSH or through DevCenter to identify & count all counters in my whole Cassandra keyspaces.

I can do the same to get all KEYSPACES

cassandra@cqlsh> desc KEYSPACES; 

Above gives me list of all keyspaces present in Cassandra. Similar I can do to get Tables.

cassandra@cqlsh> desc TABLES; 

but I want to find all counters, which will give me similar results as above CQLs??

Upvotes: 1

Views: 109

Answers (1)

Alex Ott
Alex Ott

Reputation: 87119

There is no separate command for it (and couldn't be), but you can achieve needed functionality using cqlsh & scripting, like this:

cqlsh -e 'describe schema;'|grep -e '^CREATE TABLE'| \
    sed -e "s|^CREATE TABLE \(.*\) (.*$|\1|" | \
    while read TBL ; do 
      if cqlsh -e "describe $TBL;"|grep -i -e '\S counter' >| /dev/null; then
       echo "$TBL"
      fi
    done

Upvotes: 1

Related Questions