Thursday 15 February 2018

Cassandra Data Dictionary CSQL QUERIES AND SCRIPTS

Cassandra Data Dictionary CSQL QUERIES AND SCRIPTS

1)

How to List All Tables in Cassandra ?


The keyspace is another term for the name of the database that you are using. For example, I can type in: use db;
There you go! The command lists all tables within that key space.

===================================================================

Assuming that the path of the file with the CQL commands is /mydir/myfile.cql, there are two ways:
If you are not logged in to cqlsh:
cqlsh -u 'my_username' -p 'my_password' -f /mydir/myfile.cql
If you are logged in to cqlsh:
SOURCE '/mydir/myfile.cql'
Notice the single quotation marks. The shorthand notation for $HOME (for example, '~/mydir/myfile.cql') is also supported.
Both ways also work with relative paths (to the current directory).
================================================================
3) Keyspace, table, and column information ?




An alternative to the cqlsh describe_* functions or using DevCenter to discover keyspace, table, and column information is querying system.schema_* table directly.

Procedure

  • Query the defined keyspaces using the SELECT statement.
    cqlsh> SELECT * FROM system.schema_keyspaces;

  • Query schema_columnfamilies about a particular table.
    cqlsh> SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = 'cycling' AND columnfamily_name = 'cyclist_name';
  • Query schema_columns about the columns in a table.
    cqlsh> SELECT * FROM system.schema_columns WHERE keyspace_name = 'cycling' AND columnfamily_name = 'cyclist_name';
=================================================================================

4) How to find out dropped columns ?

cqlsh:system_schema> select * from system_schema.dropped_columns; keyspace_name | table_name | column_name | dropped_time | type ---------------+------------+-------------+--------------------------+------ dev | foo | baz | 2016-02-07 05:26:10+0000 | text

==============================================================================
5) How to  get column names of a columnfamily?

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

=========================================================================================
6) 



No comments:

Post a Comment

Cassandra Authentication and Create User

Cassandra Authentication and Create User: By default when we install cassandra on a machine it do not has any username and password a...