Reputation: 317
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.
Upvotes: 3
Views: 3027
Reputation: 1
rows = session.execute("SELECT count(*) FROM system_schema.tables WHERE keyspace_name = 'your_keyspace_name'")
print(list(rows))
Result:
[Row(count=2)]
Upvotes: 0
Reputation: 57798
And for a Cassandra 2.x (and lower) answer:
SELECT COUNT(*) FROM system.schema_columnfamilies
WHERE keyspace_name='your keyspace';
Upvotes: 3
Reputation: 6228
SELECT count(*) FROM system_schema.tables WHERE keyspace_name='your keyspace'
The above query will work in cassandra 3.0 and above
Upvotes: 3