Cassandra: get columnmamily column names?

I am wondering if there is a query in CQL3 that allows you to get the column names of a specific column that has a static schema?
Thanks in advance:)

+5
source share
3 answers

You can use systemkeypace for this:

SELECT column_name FROM system.schema_columnfamilies 
  WHERE keyspace_name = 'testks' AND columnfamily_name = 'testcf';

Output in cqlsh (using cql3):

 column_name
-------------
    password

You can process the key for a column using:

SELECT key_aliases FROM system.schema_columnfamilies WHERE keyspace_name='testks' 
AND columnfamily_name='testcf';

Conclusion:

 key_aliases
--------------
 ["username"]
+8
source

If you want to get the column names of a specific table with CQL3 , then I think try this

select * from system.schema_columns WHERE keyspace_name='#KS' AND columnfamily_name='#CF' allow filtering;

: keypace_name where . (, ).

+9

From my last test, we should use schema_columns rather than schema_columnfamilies to get all column names. schema_columnfamilies can be used to get table names.

  • Get column names:

    SELECT column_name FROM system.schema_columns WHERE keyspace_name = 'KeySpaceName' AND columnfamily_name = 'TableName';
    
  • Get column names, i.e. table names:

    select columnfamily_name from system.schema_columnfamilies where keyspace_name='KeySpaceName';
    
+3
source

All Articles