I'm wondering if there is a query in CQL3 that allows you to get column names of a specific columnfamily that has a static schema?
Thanks in advance :)
To Select the data from Cassandra , Select statement is used. If you need to select all columns , you can use "*" or provide list of column names.
Use the DISTINCT keyword to return only distinct (different) values of partition keys. The FROM clause specifies the table to query. You may want to precede the table name with the name of the keyspace followed by a period (.). If you do not specify a keyspace, Cassandra queries the current keyspace.
Using Keyspace To select a keyspace in Cassandra and perform actions on it, use the keyword USE . The CQL shell switches to the name of the keyspace you specified. To change the current keyspace, use the same command with another name.
If you want to get column names of a specific table with CQL3 then i guess try this
select * from system.schema_columns WHERE keyspace_name='#KS' AND columnfamily_name='#CF' allow filtering;
Note: keyspace_name in the where clause is optional. Its mainly used for better filtration purpose (say, table with the same name in multiple keyspace)
You could use the system
keyspace to do 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 work out the key for the column by using:
SELECT key_aliases FROM system.schema_columnfamilies WHERE keyspace_name='testks'
AND columnfamily_name='testcf';
Output:
key_aliases
--------------
["username"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With