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.
And for a Cassandra 2.x (and lower) answer:
SELECT COUNT(*) FROM system.schema_columnfamilies
WHERE keyspace_name='your keyspace';
SELECT count(*) FROM system_schema.tables WHERE keyspace_name='your keyspace'
The above query will work in cassandra 3.0 and above
rows = session.execute("SELECT count(*) FROM system_schema.tables WHERE keyspace_name = 'your_keyspace_name'")
print(list(rows))
Result:
[Row(count=2)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.