ALTER KEYSPACE

Change property values of a keyspace.

Change property values of a keyspace.

Synopsis

ALTER  KEYSPACE | SCHEMA  keyspace_name
WITH REPLICATION = map
|  WITH DURABLE_WRITES =  true | false 
AND  DURABLE_WRITES =  true | false

map is a map collection, a JSON-style array of literals:

{ literal : literal , literal : literal, ... }

Table 1. Legend
  • Uppercase means literal
  • Lowercase means not literal
  • Italics mean optional
  • The pipe (|) symbol means OR or AND/OR
  • Ellipsis (...) means repeatable

A semicolon that terminates CQL statements is not included in the synopsis.

Description

ALTER KEYSPACE changes the map that defines the replica placement strategy and/or the DURABLE_WRITES value. You can also use the alias ALTER SCHEMA. Use these properties and values to construct the map. To set the replica placement strategy, construct a map of properties and values, as shown in the table of map properties on the CREATE KEYSPACE reference page. CQL property map keys must be lower case. For example, class and replication_factor are correct.

You cannot change the name of the keyspace.

Example

Change the definition of the mykeyspace to use the NetworkTopologyStrategy in a single data center. Use the default data center name in Apache Cassandra and a replication factor of 3.

ALTER KEYSPACE "Excalibur" WITH REPLICATION =
  { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 };