CREATE KEYSPACE
Synopsis
The CREATE KEYSPACE
statement creates a keyspace
that functions as a grouping mechanism for database objects (such as tables or types).
Syntax
Diagram
create_keyspace
keyspace_properties
Grammar
create_keyspace ::= CREATE { KEYSPACE | SCHEMA } [ IF NOT EXISTS ] keyspace_name
[ WITH REPLICATION '=' '{' keyspace_property '}']
[ AND DURABLE_WRITES '=' { true | false } ]
keyspace_property ::= property_name = property_value
Where
keyspace_name
andproperty_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
already exists unlessIF NOT EXISTS
option is present. - CQL keyspace properties are supported in the syntax but have no effect internally (where YugabyteDB defaults are used instead).
Examples
cqlsh> CREATE KEYSPACE example;
cqlsh> DESCRIBE KEYSPACES;
example system_schema system_auth system
cqlsh> DESCRIBE example;
CREATE KEYSPACE example WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND DURABLE_WRITES = true;
cqlsh> CREATE SCHEMA example;
SQL error: Keyspace Already Exists
CREATE SCHEMA example;
^^^^^^
See also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .