Site icon Narayana Tutorial

How to alter Cassandra Keyspace

How to alter Cassandra Keyspace

In this article, I am going to show How to alter Cassandra Keyspace. ALTER KEYSPACE can be used to alter properties such as the number of replicas and the durable_writes of a KeySpace

Syntax

ALTER KEYSPACE <identifier> WITH <properties>

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

 

Example

Existing keyspace details:

Keyspace name:  narayanatutorial

Replication factor: 1

In the alter keyspace, changing the replication factor to 2.

ALTER KEYSPACE narayanatutorial WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : '2'}

 

Keyspace Commands

 

References

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

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