# Alter Keyspace in Cassandra

Cassandra Alter Keyspace
In a created keyspace, we can alter the replication factor, strategy name and the durable_writes properties using the “ALTER keyspace” command in Cassandra.

Syntax 1:

ALTER KEYSPACE  WITH


Syntax 2:

ALTER KEYSPACE "KeySpace_Name"
WITH replication = {'class': 'Strategy name', 'replication_factor': 'No. Of  replicas'};


Syntax 3:

ALTER KEYSPACE Keyspace_Name with replication={'class':'Strategy_Name',
'replication_factor': no of replications on different nodes}
with DURABLE_WRITES=true/false


## Important Points:

• Keyspace Name: The Keyspace Name cannot be altered once created.
• The Strategy Name can be replaced with a new strategy name.
• The Replication Factor can be replaced with a new replication factor.
• The DURABLE_WRITES can be altered. It is set to true, by default. It can be set to false. And then no updates will be written to the commit log and vice versa.

Example:

ALTER KEYSPACE example WITH replication = {'class':'NetworkTopologyStrategy', 'replication_factor' : 3};

Explanation:
In the above example, ‘example’ is a keyspace and we are changing the keyspace strategy to ‘NetworkTopologyStrategy’ from ‘SimpleStrategy’. We are also changing the replication_factor from 1 to 3.