Spring Boot + Apache Cassandra
- Open Cassandra CQL Shell:
$ docker compose exec -it cassandra-node1 /bin/bash
$ cqlsh -u cassandra -p password123
- Create Cassandra keyspace with name
customer_ks
:
cqlsh> CREATE KEYSPACE customer_ks WITH replication={'class':'SimpleStrategy', 'replication_factor':1};
- Create
customer
table in customer_ks
keyspace:
cqlsh> USE customer_ks;
cqlsh:customer_ks> CREATE TABLE customer(id int PRIMARY KEY,firstname text,lastname text,age int);
- Create an index on
firstname
column:
cqlsh:customer_ks> CREATE INDEX ON customer_ks.customer (firstname);
- Verify and Query
customer
table:
cqlsh:customer_ks> DESCRIBE TABLE customer;
cqlsh:customer_ks> SELECT * FROM customer;