Create database in Cassandra
Last Updated :
12 Jul, 2025
In this article, we are going to discuss how to create the database in Cassandra. so, for better understanding you can read "
Introduction to Cassandra" article before creating a database in Cassandra.
Step-1: login into cqlsh
you can log in into the cqlsh using Cassandra default credential. Now, here before creating a database you first need login into cqlsh. you can check the cluster information after login into cqlsh.let's have a look.
cqlsh 127.0.0.1 -u cassandra -p cassandra
Step-2: Creating a database
Creating a keyspace in Cassandra is the same as creating a database in SQL. CQL query for creating a keyspace as following.
Syntax:
CREATE KEYSPACE [IF NOT EXISTS] keyspace_name
WITH REPLICATION = {replication_map}
[AND DURABLE_WRITES = true|false] ;
Here’s an example that shows how to create a keyspace named App_data:
you must read
replication strategy in Cassandra for better understanding.
Replication Strategy : NetworkTopologyStrategy
cqlsh> CREATE KEYSPACE IF NOT EXISTS App_data
WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy',
'datacenter1' : 3, 'datacenter2': 2 };
Now, here you must check If there are no errors, the database is created, or not then You can run the describe keyspaces command to ascertain that the database did indeed create the keyspace.
To check the all keyspaces which are already created then you can run the following CQL query given below.
cqlsh> describe keyspaces;
To check the App_data keyspaces is created or not then you can run the following CQL query given below.
cqlsh> describe App_data;
Output:
cassandra@cqlsh> describe keyspaces;
university system backup_copy system_traces system_schema
system_auth app_data system_distributed operation
In Cassandra, IF NOT EXISTS part is optional but it is always good practice using such statements because it helps avoid an error should the keyspace cycling already exist.
Step-3: Describing the keyspace
In Cassandra, A keyspace is a defining container for replication. Now, You can see the new keyspace App_data in the list of keyspaces shown by the database.
Now, to check the details about App_data keyspace, you can execute the describe App_data command.
describe App_data;
Output:
cassandra@cqlsh> describe App_data;
CREATE KEYSPACE app_data WITH
replication = {'class': 'NetworkTopologyStrategy',
'datacenter1': '3', 'datacenter2': '2'}
AND durable_writes = true;
Similar Reads
Cassandra (NoSQL) Database Recent Topics on Cassandra: Introduction Cassandra Architecture Cassandra Query Language Data Types Collection Data Types Functions in Cassandra Data Modelling and Designing Security Performance Monitoring Backup and Restore Data Misc Introduction Apache Cassandra (NoSQL) database Introduction to Ap
2 min read
Cassandra (NoSQL) Database Recent Topics on Cassandra: Introduction Cassandra Architecture Cassandra Query Language Data Types Collection Data Types Functions in Cassandra Data Modelling and Designing Security Performance Monitoring Backup and Restore Data Misc Introduction Apache Cassandra (NoSQL) database Introduction to Ap
2 min read
Creating a table in Cassandra In this article, we are going to discuss how we can create a table in Cassandra and also discuss column definitions, keys role, Table options (compact storage and clustering order), etc. In Cassandra, the CQL table has a name and it stores rows. when you create a table, you define the columns for th
3 min read
Creating a table in Cassandra In this article, we are going to discuss how we can create a table in Cassandra and also discuss column definitions, keys role, Table options (compact storage and clustering order), etc. In Cassandra, the CQL table has a name and it stores rows. when you create a table, you define the columns for th
3 min read
Apache Cassandra (NOSQL database) In this article, we will learn the basics of Apache Cassandra and the basics of CQL (Cassandra Query Language) operations like Create, insert, delete, select, etc. Apache CassandraApache Cassandra is an open-source NoSQL database that is used for handling big data. Apache Cassandra has the capabilit
2 min read
Apache Cassandra (NOSQL database) In this article, we will learn the basics of Apache Cassandra and the basics of CQL (Cassandra Query Language) operations like Create, insert, delete, select, etc. Apache CassandraApache Cassandra is an open-source NoSQL database that is used for handling big data. Apache Cassandra has the capabilit
2 min read