24

How can I get list of all column families in keyspace in Cassandra using CQL 3?

Aaron
  • 55,518
  • 11
  • 116
  • 132
newbie
  • 24,286
  • 80
  • 201
  • 301

4 Answers4

39

Or even more simply (if you are using cqlsh), switch over to your keyspace with use and then execute describe tables:

cqlsh> use products;
cqlsh:products> describe tables;

itemmaster    itemhierarchy         companyitemfavorites
testtable

Note: The describe command is specific to cqlsh only.

Aaron
  • 55,518
  • 11
  • 116
  • 132
23
cqlsh> select columnfamily_name from system.schema_columnfamilies where keyspace_name = 'test';

 columnfamily_name
-------------------
           commits
               foo
     has_all_types
      item_by_user
              test
             test2
      user_by_item

(7 rows)
Mikhail Stepura
  • 3,374
  • 20
  • 16
  • 7
    As of Cassandra 3.0, this should be: `SELECT table_name FROM system_schema.tables WHERE keyspace_name = 'test';` – etienne Sep 07 '16 at 16:36
11

CQL API supports both TABLES and COLUMNFAMILIES:

$ cqlsh
cqlsh> DESCRIBE KEYSPACES;
cqlsh> USE keyspace_shaharma;

see column families,

cqlsh:keyspace_shaharma> DESCRIBE COLUMNFAMILIES;

or

cqlsh:keyspace_shaharma> DESCRIBE TABLES;
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
prayagupa
  • 30,204
  • 14
  • 155
  • 192
2

To list the column family or tables in the keyspace :

  1. By using select Query:

    SELECT table_name FROM system_schema.tables WHERE keyspace_name ='mydb';

  2. By selecting Keyspace and then we can list the tables available inside the keyspace :

    use keyspace_name describe tables;

  3. By using Describe Keyword:

    describe COLUMNFAMILIES;