Apache Cassandra with docker.
1. Installed from docker
$ docker pull cassandra:latest
$ docker run --name you_cass_cluster cassandra:latest
$ docker ps
$ docker exec -it you_cass_cluster cqlsh
2. Supported Data Types.
3. Created on KEYSPACES with next command.
CREATE KEYSPACE test_kesypace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = 'true';
4. Created Tables
use test_kesypace;
CREATE TABLE employee_by_id
(id INT PRIMARY KEY,
name TEXT,
position TEXT
);
CREATE TABLE employee_by_car_make
(
car_make TEXT,
id INT,
car_model TEXT,
PRIMARY KEY(car_make, id)
);
CREATE TABLE employee_by_car_make_sorted
(
car_make TEXT,
age INT,
id INT,
name TEXT,
PRIMARY KEY(car_make, age, id)
);
CREATE TABLE employee_by_car_make_and_model
(
car_make TEXT,
car_model TEXT,
id INT,
name TEXT,
PRIMARY KEY((car_make, car_model), id)
);
5. Insert and update
INSERT INTO employee_by_id
(id,
name,
position)
VALUES ( 1,
'Henry',
'Developer');
UPDATE employee_by_car_make
using ttl 60
SET car_model = 'Truck'
WHERE car_make ='TOYOTA'
AND id = 1;
6. SELECT
SELECT *
FROM employee_by_id
WHERE id = 1;
References:
https://www.youtube.com/channel/UCHRnRlWQuZYDmnuB7SbXIpQ
No comments:
Post a Comment