Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain number of tables in a keyspace in Cassandra?

For example, we can use

select count(*) from student_database;

to calculate the number of rows in a table. But how do we calculate the number of tables in a keyspace?

DESCRIBE TABLES;

gives you the list of all tables in that keyspace.

like image 737
Kangkan Lahkar Avatar asked Jan 23 '26 23:01

Kangkan Lahkar


2 Answers

SELECT count(*) FROM system_schema.tables WHERE keyspace_name='your keyspace'

The above query will work in cassandra 3.0 and above

like image 85
undefined_variable Avatar answered Jan 27 '26 00:01

undefined_variable


And for a Cassandra 2.x (and lower) answer:

SELECT COUNT(*) FROM system.schema_columnfamilies 
    WHERE keyspace_name='your keyspace';
like image 45
Aaron Avatar answered Jan 26 '26 23:01

Aaron