Database Reference
In-Depth Information
CREATE/ALTER KEYSPACE
or modify top-level strategy options for a collection of tables. When creating a
keyspace, the keyspace name must be alphanumeric with a length of 32 or less.
There are two supported properties for the
CREATE
/
ALTER KEYSPACE
com-
mands,
replication
and
durable_writes
. When specifying
replic-
ation
, you may choose one of two options, SimpleStrategy and NetworkTo-
pologyStrategy. SimpleStrategy will create a replication factor that is consistent
across the entire cluster, and the only option available is the
replica-
tion_factor
, which must be defined. NetworkTopologyStrategy allows you
to decide the replication factor for each individual data center. The
dur-
able_writes
option specifies whether or not to use the CommitLog when writ-
ing data. This is on by default and should not be turned off as data loss could result
in the event of an outage.
Listing 4.2
Example Usage of
CREATE KEYSPACE
CREATE KEYSPACE Analytics
WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 3};
CREATE KEYSPACE Analytics
WITH replication = {'class': 'NetworkTopo-
logyStrategy', 'west' : 1, 'east' : 3}
AND durable_writes = false;
USE
ing in. This works exactly like the
USE
statement in SQL.
Listing 4.3
Example Usage of
USE
USE Analytics;