Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
60 views19 pages

Apache Cassandra Basics Guide

Cassandra is a distributed database from Apache that is highly scalable and high-performance. It provides a cqlsh shell to define schemas, insert data, and execute queries. Keyspaces are namespaces that define data replication, tables can be created and altered within keyspaces, and data can be inserted, updated, selected and deleted from tables using CQL commands. Cloud storage provides benefits like automatic updates and ability to grow with users, while disadvantages include costs, reliance on internet, and privacy concerns.

Uploaded by

Aditya Patagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views19 pages

Apache Cassandra Basics Guide

Cassandra is a distributed database from Apache that is highly scalable and high-performance. It provides a cqlsh shell to define schemas, insert data, and execute queries. Keyspaces are namespaces that define data replication, tables can be created and altered within keyspaces, and data can be inserted, updated, selected and deleted from tables using CQL commands. Cloud storage provides benefits like automatic updates and ability to grow with users, while disadvantages include costs, reliance on internet, and privacy concerns.

Uploaded by

Aditya Patagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Cassandra-Basics

Sensitivity: Internal & Restricted


Cassandra - Introduction

• Cassandra is a distributed database from Apache.


• Apache Cassandra is a highly scalable
• high-performance
•  It is a type of NoSQL database

Sensitivity: Internal & Restricted


Cassandra - Cqlsh

• Cassandra provides a prompt Cassandra query language shell (cqlsh)


• Using cqlsh, you can define a schema, insert data, and execute a
query.

Sensitivity: Internal & Restricted


Shell Commands

• HELP − Displays help topics for all cqlsh commands


• COPY − Copies data to and from Cassandra.
• DESCRIBE − Describes the current cluster of Cassandra and its objects.
• PAGING − Enables or disables query paging.
• cqlsh --version - Provides the version of the cqlsh you are using.
• TRACING − Enables or disables request tracing

Sensitivity: Internal & Restricted


CQL Data Definition Commands

• CREATE KEYSPACE − Creates a KeySpace in Cassandra.


• USE − Connects to a created KeySpace.
• ALTER KEYSPACE − Changes the properties of a KeySpace.
• DROP KEYSPACE − Removes a KeySpace
• CREATE TABLE − Creates a table in a KeySpace.
• ALTER TABLE − Modifies the column properties of a table.
• DROP TABLE − Removes a table.
• TRUNCATE − Removes all the data from a table.
• CREATE INDEX − Defines a new index on a single column of a table.
• DROP INDEX − Deletes a named index.

Sensitivity: Internal & Restricted


CQL Data Manipulation Commands And
CQL Clauses

• INSERT − Adds columns for a row in a table.


• UPDATE − Updates a column of a row.
• DELETE − Deletes data from a table.
• BATCH − Executes multiple DML statements at once.

• SELECT − This clause reads data from a table


• WHERE − The where clause is used along with select to read a specific data.
• ORDERBY − The order-by clause is used along with select to read a specific
data in a specific order.

Sensitivity: Internal & Restricted


Cassandra – Create Keyspace

• A keyspace in Cassandra is a namespace that defines data replication


on nodes
• A cluster contains one keyspace per node. 
• Syntax – CREATE KEYSPACES <keyspace name> with <Properties>
• CREATE KEYSPACE “KeySpace Name” WITH
replication = {'class': ‘Strategy name’,
'replication_factor' : ‘No.Of replicas’};
• Example
• CREATE KEYSPACE New-keyspace WITH replication =
{'class’:simple-srategy', 'replication_factor' : 3};

Sensitivity: Internal & Restricted


Cassandra - Alter Keyspace

• ALTER KEYSPACE can be used to alter properties such as the number


of replicas and the durable_writes of a KeySpace
• Syntax - ALTER KEYSPACE <identifier> WITH <properties>
• ALTER KEYSPACE “KeySpace Name” WITH replication = {'class':
‘Strategy name’, 'replication_factor' : ‘No.Of replicas’};
• Example
• ALTER KEYSPACE New-keyspace WITH replication = {'class’:’simple-
srategy', 'replication_factor' : 3};

Sensitivity: Internal & Restricted


Cassandra - Drop Keyspace

• It is used to delete the keyspace that we are created


• Syntax - DROP KEYSPACE <identifier>
• DROP KEYSPACE “KeySpace name”
• DROP KEYSPACE “New-KeySpace”

Sensitivity: Internal & Restricted


Cassandra - Create Table And Cassandra - Drop Table

• ALTER KEYSPACE <identifiers> with <properties>


• ALTER KEYSPACE “KeySpace Name” WITH replication = {'class':
‘Strategy name’, 'replication_factor' : ‘No.Of replicas’};
• ALTER KEYSPACE tutorialspoint WITH replication =
{'class’:’simple-Strategy', 'replication_factor' : 3};
• Dropping table
• DROP TABLE<table name>
• DROP TABLE emp;
• DESCRIBE COLUMNFAMILIES;
• Truncate Table
• Truncate <Table name>
• Truncate student

Sensitivity: Internal & Restricted


Cassandra - Alter Table

• Syntax - ALTER (TABLE | COLUMNFAMILY) <tablename>


<instruction>
• ALTER TABLE table name ADD new column datatype;
• ALTER TABLE emp ADD emp_email text;

Sensitivity: Internal & Restricted


Creating Data in a Table
• INSERT INTO <tablename> (<column1 name>, <column2 name>....)
VALUES (<value1>, <value2>....) USING <option>
• INSERT INTO emp (emp_id, emp_name, emp_city,
emp_phone, emp_sal) VALUES(1,'ram',
'Hyderabad', 9848022338, 50000);
• INSERT INTO emp (emp_id, emp_name, emp_city,
emp_phone, emp_sal) VALUES(2,'robin',
'Hyderabad', 9848022339, 40000);
• INSERT INTO emp (emp_id, emp_name, emp_city,
emp_phone, emp_sal) VALUES(3,'rahman',
'Chennai', 9848022330, 45000);
• Select * from emp;

Sensitivity: Internal & Restricted


Updating Data in a Table

• UPDATE <tablename> SET <column name> = <new value> <column


name> = <value> WHERE <condition>
• UPDATE emp SET emp_city='Delhi',emp_sal=50000 WHERE
emp_id=2;
• Select * from emp;

Sensitivity: Internal & Restricted


Deleting Datafrom a Table

• DELETE FROM <identifier> WHERE <condition>; - syntax


• DELETE emp_sal FROM emp WHERE emp_id=3;
• For deleting whole Row
• DELETE FROM emp WHERE emp_id=3;
• Select * from emp;

Sensitivity: Internal & Restricted


Cloud-Storage

Sensitivity: Internal & Restricted


Cloud storage – Business benefits
• With cloud storage there’s no need for cd’s, external hard drive
• Data is quickly and automatically updated in cloud
• Ability to grow with its users

Sensitivity: Internal & Restricted


Advantages of cloud storage
• Usability
• Security
• Recovery
• Syncing and Updating

Sensitivity: Internal & Restricted


Disadvantages of cloud storage
• Costs
• Hard Drives
• Privacy
• Internet Connection

Sensitivity: Internal & Restricted


Thank you

Sensitivity: Internal & Restricted

You might also like