Create and Delete Keyspace
Author: Al-mamun Sarkar
Date: 2020-09-19 13:54:29
A keyspace is like an RDBMS database that is used to defines data replication on nodes.
Create Keyspace:
Syntex:
CREATE KEYSPACE WITH
CREATE KEYSPACE “KeySpace Name”
WITH replication = {'class': ‘Strategy name’, 'replication_factor' : ‘No.Of replicas’}
AND durable_writes = ‘Boolean value’;
Example (test_keyspace):
CREATE KEYSPACE test_keyspace
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
AND durable_writes = 'true';
Show available keyspaces:
DESCRIBE KEYSPACES
SELECT * FROM system_schema.keyspaces;
Using Keyspace:
use test_keyspace;
Delete Keyspace:
Syntax:
DROP KEYSPACE keyspace_name;
Example:
DROP KEYSPACE test_keyspace;