To create a keyspace, we should log in to the CQL shell. It can be found inside the bin
directory. Help create keyspace on the CQL shell provides self-explanatory help on creating the keyspace:
CREATE KEYSPACE<ksname> WITH replication = {'class':'<strategy>'[,'<option>':<val>]};
The CREATE KEYSPACE
statement creates a new top-level namespace (also known as a keyspace). Valid names are any strings constructed of alphanumeric characters and underscores. Names that do not work as valid identifiers or integers should be quoted as string literals. Properties such as replication_factor
and datacenters to replicate are specified during creation as the key-value pairs in the replication map. 'class'
(required) is the name of the replication strategy class which should be used for the new keyspace. Some often-used classes are SimpleStrategy
and NetworkTopologyStrategy
. Most strategies require additional arguments that can be supplied as key-value pairs in the...