DSE CQL
- Open cqlsh shell
# /opt/dse-6.8.15/bin/cqlsh
cqlsh>
Create Keyspace
- For Clustered Network Topology setup
- For Simple Topology setup
cqlsh> CREATE KEYSPACE IF NOT EXISTS lts WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'dc1' : 3};
cqlsh> CREATE KEYSPACE IF NOT EXISTS lts WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' };
Create Table
cqlsh> CREATE TABLE IF NOT EXISTS lts.employees (
employee_id int,
first_name text,
last_name text,
email text,
PRIMARY KEY (employee_id) );
Insert Into Table
cqlsh> INSERT INTO lts.employees (employee_id, first_name, last_name, email)
VALUES (11223344, 'Alex', 'Mason', 'alex.mason@lts.com');
cqlsh> INSERT INTO lts.employees (employee_id, first_name, last_name, email)
VALUES (21545565, 'Alan', 'Felix', 'alan.felix@lts.com');
cqlsh> INSERT INTO lts.employees (employee_id, first_name, last_name, email)
VALUES (21545578, 'Brian', 'Cole', 'brian.cole@lts.com');
Select Statement
cqlsh> select * from lts.employees;
employee_id | email | first_name | last_name
-------------+--------------------+------------+-----------
21545578 | brian.cole@lts.com | Brian | Cole
11223344 | alex.mason@lts.com | Alex | Mason
21545565 | alan.felix@lts.com | Alan | Felix