Creating a keyspace

Keyspaces are analogous to the logical databases of the relational world. A keyspace contains tables, which are usually related to each other by application, use case, or development team. When defining a keyspace, you also have the ability to control its replication behavior, specifying pairs of data center names and a numeric Replication Factor (RF).

Creating a keyspace is a simple operation and can be done like this:

CREATE KEYSPACE [IF NOT EXISTS] <keyspace_name> WITH replication = {'class': '<replication_strategy>',  '<data_center_name>':'<replication_factor>'} AND durable_writes = <true/false>;

Here is the detailed explanation of the preceding query:

  • keyspace_name: Valid keyspace names must be composed of alphanumeric ...

Get Mastering Apache Cassandra 3.x - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.