CQL Update Data

To update data in a table in Cassandra, the UPDATE command is used. Keywords: WHERE clause: Used to select the row to be updated. SET clause: Used to set the value. MUST clause: Used to include all the columns composing the primary key. Syntax 1: UPDATE <table_name> SET <column_name> = <new_value> <column_name> = <value>…. WHERE … Read more

CQL READ Data

To read data from a table in Cassandra, the SELECT command is used. Syntax 1: SELECT FROM <table_name>SELECT FROM <table_name> Syntax 2: Using WHERE clause. SELECT FROM <table name> WHERE <condition>;SELECT FROM <table name> WHERE <condition>; Example 1: SELECT * FROM employees;SELECT * FROM employees; Output: id name salary 1 Adi 50000 2 Bruno 30000 … Read more

CQL Create Table Data

To insert data into the columns of a table in Cassandra, the INSERT command is used. Syntax: INSERT INTO <table_name> (<column1_name>, <column2_name>….) VALUES (<value1>, <value2>….) USING <option>INSERT INTO <table_name> (<column1_name>, <column2_name>….) VALUES (<value1>, <value2>….) USING <option> Example: INSERT INTO employees<id, name, salary> values<1, ‘Adi’, 50000>; INSERT INTO employees<id, name, salary> values<2, ‘Bruno’, 30000>; INSERT INTO … Read more

Cassandra Batch

We can execute multiple modification statements simultaneously in Cassandra, whether it is an insert, update or delete statement. Syntax: BEGIN BATCH <insert-stmt>/ <update-stmt>/ <delete-stmt> APPLY BATCHBEGIN BATCH <insert-stmt>/ <update-stmt>/ <delete-stmt> APPLY BATCH Example: Employees table: id name salary 1 Adi 50000 2 Bruno 30000 3 Chris 60000 4 Davis 20000 5 Eliza 15000 Query: BEGIN … Read more

DROP Index in Cassandra

Cassandra DROP Index To drop a specified index in Cassandra, the DROP INDEX command is used. The index name is TableName_ColumnName_idx, in case if the index name was not specified during index creation. Syntax 1: DROP INDEXDROP INDEX Syntax 2: Drop index IF EXISTS Keyspace_Name.Index_NameDrop index IF EXISTS Keyspace_Name.Index_Name Important Points: An error will be … Read more

Create Index in Cassandra

Cassandra Create Index We can create an index in Cassandra, on the column specified by the user, by using the CREATE INDEX command. Indexes are created on the data if the data already exists for the selected column. Syntax: CREATE INDEX indexIdentifier ON tablename Important Points: The primary key in Cassandra is already indexed and … Read more

Alter Table in Cassandra

Cassandra Alter Table To alter an existing table, the ALTER TABLE command is used. This command can be used to add a column or to Drop a column. Syntax: ALTER (TABLE | COLUMN_FAMILY) tablename instruction To Add a Column: The column name should not conflict with the existing column names. The table should not be … Read more

Truncate Table in Cassandra

Cassandra Truncate Table To truncate a table in Cassandra, the TRUNCATE command is used. Thus, all the rows are deleted permanently from the table, but the table structure exists. Syntax: TRUNCATE table_name Example: Employees table: id name salary 1 Adi 50000 2 Bruno 30000 3 Chris 60000 4 Davis 20000 5 Eliza 15000id name salary … Read more

DROP Table in Cassandra

Cassandra DROP Table To drop a table in Cassandra, the DROP TABLE command is used. Syntax: DROP TABLE table_name Example: DROP TABLE employees;DROP TABLE employees; Explanation: In the above example, the table named “employees” is dropped. Use the “DESCRIBE” command for the verification of the table deletion. DESCRIBE COLUMNFAMILIES;

Create Table in Cassandra

Cassandra Create Table To create a table, the CREATE TABLE command is used in Cassandra. In Cassandra, a column family works just like a table in RDBMS, thus a column family is created in Cassandra, instead of a table. Syntax 1: CREATE (TABLE | COLUMNFAMILY) (” , ”) (WITH AND ) Syntax 2: Declaring a … Read more