The Cassandra Insert Command is used to insert one or more columns in the base table. The list of columns should be mentioned in the value clause. By default, Cassandra does not check the prior existence of a row and creates it if it does not exist, otherwise, Cassandra updates the row.

Insert Table

The Insert Table command is used to insert the data in the base table. The following is the syntax of the Cassandra Insert Table command.

INSERT INTO keyspacename.tablename (columnlist)
VALUES (columnvalues);

In the following example section, let's create a table named emp_detail in the Cloudduggu keyspace and insert the records using the Insert Table of Cassandra.

cqlsh> CREATE TABLE cloudduggu.emp_detail (
   emp_id INT PRIMARY KEY,
   emp_first_name TEXT,
   emp_last_name TEXT,
   emp_state TEXT,
   zip INT
) ;

cqlsh> INSERT INTO cloudduggu.emp_detail (emp_id, emp_first_name, emp_last_name, emp_state, zip  ) VALUES (1001, 'Ram','Kumar','MP', 564567);

cqlsh> INSERT INTO cloudduggu.emp_detail (emp_id, emp_first_name, emp_last_name, emp_state, zip  ) VALUES (1002, 'Mohan','Sharma','UP', 786789);

cqlsh> INSERT INTO cloudduggu.emp_detail (emp_id, emp_first_name, emp_last_name, emp_state, zip  ) VALUES (1003, 'Ritu','Raj','MAH', 345234);

cqlsh> INSERT INTO cloudduggu.emp_detail (emp_id, emp_first_name, emp_last_name, emp_state, zip  ) VALUES (1004, 'Animesh','Dutta','JK', 923487);

cqlsh> INSERT INTO cloudduggu.emp_detail (emp_id, emp_first_name, emp_last_name, emp_state, zip  ) VALUES (1005, 'Manoj','Gopa','GUJ', 563456);

Command Output:
cassandra insert command cloudduggu

Let's verify the output using the Select command to see if the rows are inserted in the table.

Verify Output:
cqlsh> SELECT * FROM cloudduggu.emp_detail;

cassandra select output cloudduggu