Keyspaces API definitions

Certify and Increase Opportunity.
Be
Govt. Certified Apache Cassandra Professional

Keyspaces API definitions

The keyspace is the container for your application data, similar to a schema in a relational database. Keyspaces are used to group column families together. Typically, a cluster has one keyspace per application.

Replication is controlled on a per-keyspace basis, so data that has different replication requirements should reside in different keyspaces. Keyspaces are not designed to be used as a significant map layer within the data model, only as a way to control data replication for a set of column families.
Defining Keyspaces.

Data Definition Language (DDL) commands for defining and altering keyspaces are provided in the various client interfaces, such as Cassandra CLI and CQL. For example, to define a keyspace in CQL:

CREATE KEYSPACE keyspace_name WITH
strategy_class = ‘SimpleStrategy’
AND strategy_options:replication_factor=’2′;

Or in Cassandra CLI:

CREATE KEYSPACE keyspace_name WITH
placement_strategy = ‘SimpleStrategy’
AND strategy_options = {replication_factor:2};

Creating a Keyspace

You can use the Cassandra CLI commands described in this section to create a keyspace. In this example, we create a keyspace called demo, with a replication factor of 1 and using the SimpleStrategy replica placement strategy.

Note the single quotes around the string value of placement_strategy:

[default@unknown] CREATE KEYSPACE demo
with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'
and strategy_options = {replication_factor:1};

You can verify the creation of a keyspace with the SHOW KEYSPACES command. The new keyspace is listed along with the system keyspace and any other existing keyspaces.

Configuring Cassandra
Replica and their placement

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?