/    /  Cassandra – Alter KeySpace

Cassandra – Alter KeySpace

Alter Keyspace command allows you to alter the replicaton factor, strategy name and durable writes attributes. Below the syntax for Alter KeySpace command.

Syntax:

Alter Keyspace KeyspaceName with replication=
{'class':'StrategyName', 'replication_factor': no of replications on different nodes}
with DURABLE_WRITES=true/false

Note:Using Alter command Keyspace Name cannot be changed in cassandra.

By default, DURABLE_WRITES value is true. If set to false, no updates will be written to the commit log.

Example:

cqlsh> ALTER KEYSPACE i2Tutorials
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3};
Cqlsh> Describe keyspaces;
i2tutorials  system_schema system_auth  system system_distributed system_traces

Validate the ALTER KeySpace

cqlsh:system_schema> SELECT * FROM system_schema.keyspaces;
keyspace_name      | durable_writes | replication
--------------------+----------------+-----------------------------------------------
I2Tutorials | True | {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'replication_factor':'3'}
system_auth | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor':'1'}
system_schema | True | {'class': 'org.apache.cassandra.locator.LocalStrategy'}
system_distributed | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor':'3'}
system | True | {'class': 'org.apache.cassandra.locator.LocalStrategy'}
system_traces | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor':'2'}