How to create Cassandra Keyspace

How to create Cassandra Keyspace

In this article, I am going to show How to create Cassandra Keyspace. A keyspace in Cassandra is a namespace that defines data replication on nodes. A cluster contains one keyspace per node.

Syntax

CREATE KEYSPACE <identifier> WITH <properties>

CREATE KEYSPACE “KeySpace Name” WITH replication = {'class': ‘Strategy name’, 'replication_factor' : ‘No.Of replicas’};

 

Example:

CREATE KEYSPACE narayanatutorial WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : '1'};

 

Keyspace Commands

  • CREATE KEYSPACE − Creates a KeySpace in Cassandra.
  • ALTER KEYSPACE − Changes the properties of a KeySpace.
  • DROP KEYSPACE − Removes a KeySpace
  • USE – allows to change the current keyspace

 

References

http://cassandra.apache.org/doc/latest/cql/ddl.html#create-keyspace

http://cassandra.apache.org/doc/latest/cql/ddl.html#

 

 

Leave a Reply