 Hello, and welcome to a session on credit operations in Cassandra. This is Dr. Anita Pujar, professor of computer science and engineering department from Volchian Institute of Technology, SolarPore. At the end of this session, learners will be able to write and execute credit operations that is create, read, update and delete operations in Cassandra using Cassandra query language. Now, let's go to the first operation that is create table. Now, as you know that Cassandra query language is very similar to SQL. So the syntax of create table is also very similar to the create table in SQL. So it says create table, the name of the table followed by the name of the columns and their types and also the indication of primary key. So let's consider one example that is create table employee on key space employees with attributes employee ID, name, city, salary, phone number as attributes. So the query goes like this. First assuming that a key space employees has already been created, we need to connect to the employees key space by using the statement use employees. So here the prompt changes to SQL SH employees. Now on this case space, you need to create a table employee. So write the query as create table employee with the attributes employee ID of type int and which is also set as primary key. Then comes employee name, which is of data type text, then employee city. It is also of type text followed by employee salary, which is of type variant and employee phone number, which is also variant. Now next is how to insert the data into this table. So data can be inserted into the table by using insert command. So syntax of the insert command, again here it is very similar to the insert command in SQL. So insert into table name followed by the names of the attributes of the table and the values that are to be assigned to these columns are specified in the values table. So let's consider an example that we want to insert the three rows as follows into the employee table. So this can be done in two ways. So first one is using insert command separately on Cassandra shell prompt. So three insert commands separately on Cassandra shell prompt is specified as follows. And the second method is to embed all these multiple insert commands into one batch file. So specify the command begin batch, insert all the queries, three queries into it and then say apply batch. So this will create all the three rows into the table employee. Now the next operation is the read operation. We can read the data from the table using select statement. So now if I want to verify whether the data has been inserted into employee table. So I use the select clause as follows. Select star from employee. So it shows all the three rows that have been inserted into the employee table. Now read operation shows even how to read particular columns in the table. For example, select employee name employee salary from employee. So this displays only two columns that is employee name and employee salary of all the employees in the table. Next read operation can also be used with where clause. For example, if I want to read the employee records based on certain condition, then that condition is specified in the where clause. So select star from employee where employee salary is greater than 75000. So this query displays only those employees records whose salary is greater than 75000. Now let's see the next operation that is update operation. Update is a command used to update the data in the table. The following keywords are used with update command. First one is where. This clause is used to select the particular rows which are to be updated. Update clause is used to set the value of the columns to the new value and must keyword includes all the columns composing the primary key. Note if a given row that is to be updated is unavailable in the table then update command creates a fresh row. Now let's see the syntax of update operation. So update table name set the column names with the new values and where condition specifies only those rows for which the updation needs to be done. Now let's consider one example. Update employee city of employee whose ID is 102 to Delhi and his salary to 1 lakh. So the query is as follows update table name is employee set EMP city employee city is equal to Delhi earlier it was Pune and employee salary is equal to 1 lakh where employees ID is equal to 102. So this updation will be done only to an employee whose ID is 102. For verification of update again use the select statement as select star from EMP. So it will display all the rows of the table. Now let's see the last operation that is delete operation command which is used to delete the data from the table. So there are different types of deleting data from the table. First one is deleting a row from the table whose syntax is as follows delete from table name where condition. So where is used to select one or more rows for deletion. Next deleting a column from the table so syntax is delete specify the column names column name will be one or more column names from the table name where condition again where is used for deleting particular rows. Now let's see an example for these deletions delete from employee where employee ID is equal to 103. So this query will delete only one row from the employee table where employee ID is equal to 103. Now delete employee salary from EMP where employee ID is equal to 103. So this statement will delete only one column that is employee salary from the table EMP that is employee where employees ID is equal to 103. So only employee salary of employee 103 is deleted from the table. Again to verify the duration of data we can use select statement. Now one more delete operation is to delete all the rows in the table without deleting a table. So there we can use truncate command that is truncate table name. For example if I want to delete all the rows in EMP table then I need to specify truncate EMP. Again we can verify the deletion of data using select statement. Now let's see how to create index on columns. Indexes help to search the required data from the database very fast. The users cannot see these indexes created but they are just used to speed up the searches or queries. So if I say select star from student where roll number in 123. So this will display all the three records of the student having roll number 123. But if I search on student name instead of roll number then this query will generate an error because student name is neither a primary key nor an index has been created on student name whereas for roll number roll number has been specified already as a primary key. So I need to first create index on student name and then use the student name for querying. So create index on student info where student info is a table name and on attribute or column student name. Now I can use the student name for searching the records. So I will use the query as select star from student info where student name is equal to xyz. Students will immediately locate a record of the student whose name is equal to xyz and it will display the whole record of that student. Now let's pause the video, think and write. What type of lines can be executed in Cassandra? There are two type of statements that can be executed in Cassandra. One is commands such as capture, describe, color and so on. And second is queries that is create, read, update and delete operations. So are we able to execute both the things that is only a can be executed or only b can be executed both a and b can be executed. So answer is both can be executed because statements can also be executed on Cassandra shell and as well as queries can also be executed on Cassandra shell and we have seen that in the earlier slides. Now what command is used to delete all the rows in the table? Is it clear, truncate, delete or drop? So you already know that drop is used for deleting the whole table. Delete is used for deleting one or more rows or deleting one or more columns. And clear is not at all a command for deleting the data in databases. So truncate is the only command used to delete all the rows in the table without deleting the table. So these are the answers as I have discussed. These are some of the references. Thank you.