How to list column families in keyspace?

别来无恙 提交于 2019-12-06 16:50:36

问题


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


回答1:


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)



回答2:


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.




回答3:


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;



回答4:


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;



来源:https://stackoverflow.com/questions/22734191/how-to-list-column-families-in-keyspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!