Cassandra Data Dictionary CSQL QUERIES AND SCRIPTS
1)
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
=================================================================================
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
==============================================================================
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