Schema descriptions in Cassandra
Last Updated :
04 May, 2020
In this article, we will discuss where we can use describe commands, how it will help to describe schema, also discuss how describe command is useful. Let’s discuss one by one.
Describe command is very helpful in CQL just because it gives the description of the newly created database, newly created table, description of function if any, description of any user-defined function if any. You can see the following points listed for describe commands.
- It gives information about Cluster.
- It provides information about Index type created on any table.
- It gives the information of newly created database.
- It also gives the information about function.
- It gives the information of user-defined type if any.
Now, you can use the help command to see all the use cases of describe command. let’s have a look.
cassandra@cqlsh> help describe
Output:
for example:
Example: list all Existing keyspaces
cassandra@cqlsh> describe keyspaces;
Output
system_schema system backup_copy system_traces university
system_auth app_data system_distributed operation
Example: app_data keyspace schema
cassandra@cqlsh> describe app_data;
Output
CREATE KEYSPACE app_data WITH replication =
{
'class': 'NetworkTopologyStrategy',
'datacenter1': '3', 'datacenter2': '2'
}
AND durable_writes = true;
CREATE TABLE app_data.t (
k text,
i int,
s text static,
PRIMARY KEY (k, i)
) WITH CLUSTERING ORDER BY (i ASC)
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': 'org.apache.cassandra.io.compress.LZ4Compressor'
}
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';
CREATE TABLE app_data.user_data (
user_id uuid PRIMARY KEY,
address text,
name text
) WITH 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': 'org.apache.cassandra.io
.compress.LZ4Compressor'}
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';
Example: user_data table schema
cassandra@cqlsh> describe app_data.user_data;
Output
CREATE TABLE app_data.user_data (
user_id uuid PRIMARY KEY,
address text,
name text
) WITH 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': 'org.apache.cassandra.io.compress.LZ4Compressor'
}
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';
Share your thoughts in the comments
Please Login to comment...