Get Definition of Table in Cassandra - Cassandra / CQL Tutorial

Get Definition of a Table in Cassandra

Often we need to know the definition of table/s to answer many of our questions such as

  • What are the data types of column
  • Which column/s are part of Primary key
  • On which columns indexes are present
  • Want to use the definition to create the same table in other environments such as Stage, UAT etc.

You can get the definition of table by using below syntax in CQL


CQLSH:techbrotherstutorials> describe TABLE tablename;


Let's create employee table and then use describe to get the definition.

CQLSH:techbrotherstutorials>CREATE TABLE employee 
                          employeeid UUID , 
                          fname TEXT, 
                          lname TEXT, 
                          address TEXT, 
                          age TINYINT, 
                          PRIMARY KEY((employeeid,fname),lname) 
             WITH clustering 
ORDER BY     ( 
                          lname DESC);


Use Describe to get definition of employee table.

CQLSH:techbrotherstutorials> describe TABLE employee ;


CREATE TABLE techbrotherstutorials.employee (
    employeeid uuid,
    fname text,
    lname text,
    address text,
    age tinyint,
    empage int,
    PRIMARY KEY ((employeeid, fname), lname)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': ''}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';



1 comment: