Create and Delete Keyspace

Create and Delete Keyspace

Instructor-svg Al-Mamun Sarkar
Sep 19 , 2020

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;

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram