Project: YugabyteDB (App Definition and Development / Database)
File: ddl_alter_keyspace.md

title: ALTER KEYSPACE statement [YCQL] headerTitle: ALTER KEYSPACE linkTitle: ALTER KEYSPACE description: Use the ALTER KEYSPACE statement to change the properties of an existing keyspace. menu: v2.18: parent: api-cassandra weight: 1200 type: docs 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. <svg class="rrdiagram" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="471" height="65" viewbox="0 0 471 65"><path class="connector" d="M0 22h5m58 0h30m82 0h20m-117 0q5 0 5 5v20q0 5 5 5h5m71 0h16q5 0 5-5v-20q0-5 5-5m5 0h10m110 0h10m141 0h5"/><rect class="literal" x="5" y="5" width="58" height="25" rx="7"/><text class="text" x="15" y="22">ALTER</text><rect class="literal" x="93" y="5" width="82" height="25" rx="7"/><text class="text" x="103" y="22">KEYSPACE</text><rect class="literal" x="93" y="35" width="71" height="25" rx="7"/><text class="text" x="103" y="52">SCHEMA</text><a xlink:href="../grammardiagrams#keyspace-name"><rect class="rule" x="205" y="5" width="110" height="25"/><text class="text" x="215" y="22">keyspacename</text></a><a xlink:href="../grammardiagrams#keyspace-properties"><rect class="rule" x="325" y="5" width="141" height="25"/><text class="text" x="335" y="22">keyspaceproperties</text></a></svg> <svg class="rrdiagram" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="888" height="110" viewbox="0 0 888 110"><path class="connector" d="M0 52h25m53 0h10m101 0h10m30 0h10m28 0h30m-5 0q-5 0-5-5v-20q0-5 5-5h59m24 0h59q5 0 5 5v20q0 5-5 5m-5 0h30m28 0h20m-497 0q5 0 5 5v8q0 5 5 5h472q5 0 5-5v-8q0-5 5-5m5 0h30m46 0h10m133 0h10m30 0h30m45 0h22m-82 0q5 0 5 5v20q0 5 5 5h5m47 0h5q5 0 5-5v-20q0-5 5-5m5 0h20m-361 0q5 0 5 5v38q0 5 5 5h336q5 0 5-5v-38q0-5 5-5m5 0h5"/><rect class="literal" x="25" y="35" width="53" height="25" rx="7"/><text class="text" x="35" y="52">WITH</text><rect class="literal" x="88" y="35" width="101" height="25" rx="7"/><text class="text" x="98" y="52">REPLICATION</text><rect class="literal" x="199" y="35" width="30" height="25" rx="7"/><text class="text" x="209" y="52">=</text><rect class="literal" x="239" y="35" width="28" height="25" rx="7"/><text class="text" x="249" y="52">{</text><rect class="literal" x="351" y="5" width="24" height="25" rx="7"/><text class="text" x="361" y="22">,</text><a xlink:href="../grammardiagrams#keyspace-property"><rect class="rule" x="297" y="35" width="132" height="25"/><text class="text" x="307" y="52">keyspaceproperty</text></a><rect class="literal" x="459" y="35" width="28" height="25" rx="7"/><text class="text" x="469" y="52">}</text><rect class="literal" x="537" y="35" width="46" height="25" rx="7"/><text class="text" x="547" y="52">AND</text><rect class="literal" x="593" y="35" width="133" height="25" rx="7"/><text class="text" x="603" y="52">DURABLE_WRITES</text><rect class="literal" x="736" y="35" width="30" height="25" rx="7"/><text class="text" x="746" y="52">=</text><rect class="literal" x="796" y="35" width="45" height="25" rx="7"/><text class="text" x="806" y="52">true</text><rect class="literal" x="796" y="65" width="47" height="25" rx="7"/><text class="text" x="806" y="82">false</text></svg> ```ebnf alterkeyspace ::= ALTER { KEYSPACE | SCHEMA } keyspacename [ WITH REPLICATION '=' '{' keyspace_property '}'] [ AND DURABLE_WRITES '=' { true | false } ] keyspaceproperty ::= propertyname = property_value ``` Where `keyspacename` and `propertyname` are identifiers. `property_value` is a literal of either , , or data type. 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). ```sql ycqlsh> ALTER KEYSPACE example; ``` ```sql ycqlsh> ALTER KEYSPACE example WITH DURABLE_WRITES = true; ``` ```sql ycqlsh> ALTER KEYSPACE example WITH REPLICATION = {'class': 'SimpleStrategy', 'replicationfactor': '3'} AND DURABLEWRITES = true; ``` ```sql ycqlsh> ALTER SCHEMA keyspace_example; ``` ```output SQL error: Keyspace Not Found. ALTER SCHEMA keyspace_example; ^^^^^^ ``` ```sql ycqlsh> ALTER KEYSPACE example; ``` ```output SQL error: Unauthorized. User test_role has no ALTER permission on <keyspace example> or any of its parents. ALTER KEYSPACE example; ^^^^^^ ```