Change attributes of a keyspace.
ALTER KEYSPACE <ks_name>
WITH strategy_class = <value>
[ AND strategy_options:<option> = <value> [...]
[ AND durable_writes = true | false ] ];
You can use ALTER KEYSPACE in Cassandra 1.1.6 and later to change the keyspace attributes:
You cannot change the name of the keyspace. The ALTER KEYSPACE statement must include setting the strategy class even when there is no change to the strategy class.
Continuing with the last example in CREATE KEYSPACE, change the definition of the MyKeyspace keyspace to set durable_writes to false for purposes of this example. Changing the durable_writes attribute is not recommended because it could result in data loss.
Note
These examples work with pre-release CQL 3 in Cassandra 1.1.x. The syntax differs in the release version of CQL 3 in Cassandra 1.2 and later.
ALTER KEYSPACE "MyKeyspace"
WITH strategy_class = NetworkTopologyStrategy
AND durable_writes = false;
Check the keyspace settings:
SELECT * from system.schema_keyspaces;
The output describes the defined keyspace and looks something like this:
keyspace | durable_writes | name | strategy_class | strategy_options
------------+----------------+------------+-------------------------+------------------
MyKeyspace | False | MyKeyspace | NetworkTopologyStrategy |
| CQL Commands | CQL Shell Commands |
|---|---|
| ALTER TABLE | ASSUME |
| ALTER KEYSPACE | CAPTURE |
| BATCH | COPY |
| CREATE TABLE | DESCRIBE |
| CREATE INDEX | EXIT |
| CREATE KEYSPACE | SHOW |
| DELETE | SOURCE |
| DROP TABLE | |
| DROP INDEX | |
| DROP KEYSPACE | |
| INSERT | |
| SELECT | |
| TRUNCATE | |
| UPDATE | |
| USE |