Notice: Constant WP_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 107

Notice: Constant WP_MAX_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 108
CQL Update Data - CodesJava

CodesJava

Easy learning with example program codes

CQL Update Data


Notice: Undefined variable: footnotelist in /home/javawith/public_html/codesjava.com/wp-content/plugins/latex2html/inc/core.php on line 475

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 <condition>

Syntax 2:

Update Keyspace_Name.Table_Name   
Set Column_Name1 = new Column1_Value,  
      Column_Name2 = new Column2_Value,  
      Column_Name3 = new Column3_Value,  
       ...
Where Column_Name = Column_Value

Example:
Employees table:

id	name	salary
1	Adi	50000
2	Bruno	30000
3	Chris	60000
4	Davis	20000
5	Eliza	15000

Query:

UPDATE employees SET salary = 20000 WHERE ID = 2;

Explanation:
In the above example, we are updating the value of the ‘salary’ column to 20000, where the value of ID is 2. Verify it by using the below command.
SELECT * FROM employees;

Output:

id	name	salary
1	Adi	50000
2	Bruno	20000
3	Chris	60000
4	Davis	20000
5	Eliza	15000
Please follow and like us:
error









Copyright © 2019 CodesJava DMCA.com Protection Status