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> |
Example:
INSERT INTO employees<id, name, salary> values<1, 'Adi', 50000>; INSERT INTO employees<id, name, salary> values<2, 'Bruno', 30000>; INSERT INTO employees<id, name, salary> values<3, 'Chris', 60000>; INSERT INTO employees<id, name, salary> values<4, 'Davis', 20000>; INSERT INTO employees<id, name, salary> values<5, 'Eliza', 15000>; |
Explanation:
In the above example, we are inserting data into the ’employees’ table. Verify it by using the below command.
SELECT * FROM employees;
Output:
id name salary 1 Adi 50000 2 Bruno 30000 3 Chris 60000 4 Davis 20000 5 Eliza 15000