Cassandra MATERIALIZED VIEW

Author: Al-mamun Sarkar Date: 2020-09-27 06:43:30

In this lesson, I will show how to create MATERIALIZED VIEW in Cassandra. CREATE MATERIALIZED VIEW is used to create the MATERIALIZED VIEW.

Creating MATERIALIZED VIEW:

CREATE MATERIALIZED VIEW test_keyspace.employee_drive_hatchback 
AS SELECT * FROM test_keyspace.employee_by_car_model  
WHERE model = 'HATCHBACK' 
AND car_make='BMW'
AND id IS NOT NULL
PRIMARY KEY ( model, car_make, id);

Select Data From View:

SELECT * FROM employee_drive_hatchback;

Inserting Data Into Main Table:

INSERT INTO employee_by_car_model (car_make, model, id, age, car_model)
VALUES ( 'BMW', 'HATCHBACK', 6, 33, 'Test');

Select From View:

SELECT * FROM employee_drive_hatchback;