ALTER KEYSPACE

Synopsis

Use the ALTER KEYSPACE statement to change 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

ALTERKEYSPACESCHEMAkeyspace_namekeyspace_properties

keyspace_properties

WITHREPLICATION={,keyspace_property}ANDDURABLE_WRITES=truefalse

Grammar

alter_keyspace ::= ALTER { KEYSPACE | SCHEMA } keyspace_name
                       [ WITH REPLICATION '=' '{' keyspace_property '}']
                       [ AND DURABLE_WRITES '=' { true | false } ]

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.
  • YCQL keyspace properties are supported in the syntax but have no effect internally (where YugabyteDB defaults are used instead).

Examples

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

See also