ALTER KEYSPACE

Synopsis

The ALTER KEYSPACE statement changes the properties of an existing keyspace.

This statement is supported for compatibility reasons only, and has no effect internally (no-op statement).

The statement can fail if the specified keyspace does not exist or if the user (role) has no permissions for the keyspace ALTER operation.

Syntax

Diagram

alter_keyspace

ALTER KEYSPACE - 图1

keyspace_properties

ALTER KEYSPACE - 图2

Grammar

  1. alter_keyspace ::= ALTER { KEYSPACE | SCHEMA } keyspace_name
  2. [ WITH REPLICATION '=' '{' keyspace_property '}']
  3. [ AND DURABLE_WRITES '=' { true | false } ]
  4. keyspace_property ::= property_name = property_value

Where

  • keyspace_name and property_name are identifiers.
  • property_value is a literal of either boolean, text, or map data type.

Semantics

  • An error is raised if the specified keyspace_name does not exist.
  • An error is raised if the user (used role) has no ALTER permission for this specified keyspace and no ALTER permission for ALL KEYSPACES.
  • CQL keyspace properties are supported in the syntax but have no effect internally (where YugabyteDB defaults are used instead).

Examples

  1. cqlsh> ALTER KEYSPACE example;
  1. cqlsh> ALTER KEYSPACE example WITH DURABLE_WRITES = true;
  1. cqlsh> ALTER KEYSPACE example WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND DURABLE_WRITES = true;
  1. cqlsh> ALTER SCHEMA keyspace_example;
  1. SQL error: Keyspace Not Found.
  2. ALTER SCHEMA keyspace_example;
  3. ^^^^^^
  1. cqlsh> ALTER KEYSPACE example;
  1. SQL error: Unauthorized. User test_role has no ALTER permission on <keyspace example> or any of its parents.
  2. ALTER KEYSPACE example;
  3. ^^^^^^

See also